css里怎么让input全靠左啊

html-css013

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>

可以用选择器来做,但css不能直接区分radio和checkbox,这个需要有父选择器来控制。

举例说明一下:

<div

class="radio">

<input

type="radio"

value="单选1"

/>单选1

<input

type="radio"

value="单选2"

/>单选2

<input

type="radio"

value="单选3"

/>单选3

</div>

<div

class="checkbox">

<input

type="checkbox"

value="复选1"

/>复选1

<input

type="checkbox"

value="复选2"

/>复选2

<input

type="checkbox"

value="复选3"

/>复选3

</div>

css定义:

/*---单选样式--*/

.radio

input{

width:40px

border:#ff0000

1px

solid

}

/*---多选样式--*/

.checkbox

input{

width:100px

border:#0000ff

1px

solid

}

每个input放到不同的div里,每个div调用不同的样式,大概这样写#div1{********},然后#div1 input{***************}以此类推#div2{*************}#div2 input{**************}