根本就沒有l(wèi)eft .div呀?設(shè)置沒有效果,想讓按鈕居中顯示
<!DOCTYPE?html> <html> <head> ????<meta?http-equiv="Content-type"?content="text/html;?charset=utf-8"?/> ????<title></title> ????????<script?src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> ????<style> ????.left, ????.right?{ ????????width:?300px; ????} ???? ???? ????.right?div?{ ????????width:?100px; ????????height:?90px; ????????padding:?5px; ????????margin:?5px; ????????float:?left; ????????border:?1px?solid?#639; ????} ???? ????.left?{ ????????width:300px; ????????height:50px; ????????background:?#bbffaa; ????} ????.a{ ????????width:300px; ????????margin:0px?auto; ????} ???? ????.right?div?{ ????????background:?yellow; ????} ????</style> </head> <body> ????<h2>通過empty與remove移除元素</h2> ????<div?class="left"> ????????<div?class="a"> ????????<button?id="bt1">點(diǎn)擊通過jQuery的empty移除內(nèi)部P元素</button> ????????<button?id="bt2">點(diǎn)擊通過jQuery的remove移除整個(gè)節(jié)點(diǎn)</button> ????????</div> ????</div> ????<div?class="right"> ????????<div?id="test1"> ????????????<p>p元素1</p> ????????????<p>p元素2</p> ????????</div> ????????<div?id="test2"> ????????????<p>p元素3</p> ????????????<p>p元素4</p> ????????</div> ????</div> ????<script?type="text/javascript"> ????$("#bt1").on('click',?function()?{ ????????//刪除了2個(gè)p元素,但是本著沒有刪除? ????????$("#test1").empty() ????}) ????$("#bt2").on('click',?function()?{ ????????//刪除整個(gè)節(jié)點(diǎn) ????????$("#test2").remove() ????}) ????</script> </body> </html>
想讓兩個(gè)按鈕在left中居中顯示,但沒有成功
2017-07-22
.left{
display:table-cell;
text-align:center;
}
2017-02-03
1.要么定位 2.要不就給“button”寬度然后margin: 0 auto;3.給個(gè)padding或者margin吧
2016-11-22
.a{
? ?text-align: center;
}?