第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

垂直居中的方法和技巧

關于垂直居中的,不僅僅是line-height

正在回答

1 回答

簡單的情況text-align:center; ?vertical-align:?middle等,下面是復雜一點的:

// 方法一:已知元素的高寬

?????<div></div>

?CSS:

??.content{

????????background-color:#6699FF;

????????width:200px;

????????height:200px;

????????position: absolute; ???????

????????top: 50%;

????????left: 50%;

????????/* 二分之一的負height,width ?*/

????????margin-top:-100px ;

????????margin-left: -100px;

????}

?//方法二:未知元素的高寬 ???

?????<div></div>

?CSS:

??.content{

????????background-color:#6699FF;

????????width:200px;

????????height:200px;

????????position: absolute; ???????

????????/* transform: translate(-50%,-50%) ?或 margin:auto與四邊距相等 */???

????????margin:auto; ?????/*無這個就只有top、left起作用*/

????????top: 0;

????????left: 0;??

????????bottom:0; ?

????????right: 0;

????}

//3,兩個按鈕在div中居中,并相距一定距離

<style type="text/css">

div{width: 600px;height: 500px;background-color: rgba(240,240,240,0.9);text-align:

????????center;}

.button{ width:100px;height: 90px;background-color: #f00;position: relative;top: 50%;

???????????transform: translate(0,-50%) ?}

.button1{margin-left: 0;margin-right: 100px;}

.button2{margin-right: 0;}

</style>

</head>

<body>

?<div>

? <input type="button" class="button button1"></input>

? <input type="button" ?class="button button2"></input>

?</div>


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

慕少7532173

方法2所說的未知元素寬高的居中方法,.content中不是已經(jīng)設置height和width了嗎
2016-10-21 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

垂直居中的方法和技巧

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

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號