亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

不加 radio-inline也可以水平啊

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>表單控件(復選框和單選按鈕水平排列)</title>

<link rel="stylesheet" >

</head>


<body>

<form role="form">

? ? <div class="form-group">

? ? <label class="radio-inline">

? ? ? ? <input type="radio" name="sex">男人

? ? ? ? </label>

? ? ? ? <label class="radio-inline">

? ? ? ? <input type="radio" name="sex">女人

? ? ? ? </label>

? ? ? ? <label class="radio-inline">

? ? ? ? <input type="radio" name="sex">中性

? ? ? ? </label>

? ? </div>

<div class="form-group">

? ? <label>

? ? ? ? <input type="checkbox" >男人

? ? ? ? </label>

? ? ? ? <label>

? ? ? ? <input type="checkbox" >女人

? ? ? ? </label>

? ? ? ? <label>

? ? ? ? <input type="checkbox" >中性

? ? ? ? </label>

? ? </div>

</form>

</body>

</html>


正在回答

2 回答

你沒有給label添加class="checkbox" 這樣把label默認為類聯元素 所以能夠水平顯示 但是這樣不規范

0 回復 有任何疑惑可以回復我~
#1

無瑕疵 提問者

非常感謝!
2016-08-19 回復 有任何疑惑可以回復我~

樓上回答的很正確,我來仔細分析一下,首先看源代碼

.radio,
.checkbox {
? position: relative;
? display: block;
? margin-top: 10px;
? margin-bottom: 10px;
}然后再看看

.radio input[type="radio"],
.radio-inline input[type="radio"],
.checkbox input[type="checkbox"],
.checkbox-inline input[type="checkbox"] {
? position: absolute;
? margin-top: 4px \9;
? margin-left: -20px;
}也就是說默認是內聯元素,只有加上.radio,
.checkbox類時才是塊元素(也就是才換行)

3 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

不加 radio-inline也可以水平啊

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號