css里怎么让input全靠左啊

html-css011

css里怎么让input全靠左啊,第1张

css里让input全靠左,首先我们需要获取到所有的input元素,可以通过给他们加id,class实现,当然最好的是通过标签选择器,将所有的input获取,然后在通过一个flaot:left就能实现input全靠左,请看代码:

<html>

<head>

<style>

input{

width:300px

height:30px

font-size:13px

float:left

}

</head>

<body>

<div>

<input

type='submit'

value='人人'>

<input

type='button'

value='百度'>

<input

type='text'

value='订单'>

</div>

</body>

</html>

两种解决方案:

按照百分比来做(此方案不做详细描述)

固定两侧中间为100% 然后用margin减去左右两侧的

<div style="width:100% margin:0 auto"> 

       <div style="width:50px float:left">

<input type="button" value="left" style="width:100%"/>

   </div>

   <div style="width:50px float:right">

<input type="button" value="right" style="width:100%"/>

   </div>

       <div style="margin:0 50px 0 50px">

<input type="button" value="center" style="width:100%"/>

   </div>

    </div>