的邊緣我有一個元件與屏幕尺寸1440px =爲約16.8%的保持元件
margin-left:241.5px
位置。
但是,對於1920年的屏幕尺寸,它應該是473px。
我想弄清楚我能做些什麼動態地讓它發生,所以我不必爲每個屏幕大小調整它。
我嘗試使用margin-left與%但它不起作用,與EM相同。
有沒有辦法如何動態地進行此定位?
它很難刺激的demo,但是我想
<div class="about">
<p>01</p>
</div>
html,*{
padding:0;
margin:0;
}
html{
height: 100%;
}
body{
height: 100%;
width: 100%;
}
.about{
width: 100%;
height: 100%;
background: url(http://66.media.tumblr.com/4bb5538edf278f7e83d8275e60550433/tumblr_msefuouXB81s9yt1no1_500.png) no-repeat;
background-size: 1158.6px 163px;
background-position: top 172px left 149px;
position: absolute;
}
.about p{
margin-top: 78.3px;
margin-left: 16.8%;
font-size: 22px;
position: absolute;
color: #CECED2
}
.about h6{
margin-top: 101.3px;
margin-left: 241.5px;
font-size: 22px;
position: absolute;
color: #151416;
}
您可以使用媒體查詢來代替。當然,你將不得不爲不同的屏幕尺寸編寫。但您可以使用媒體查詢來管理它。 –
我想嘗試它,如果可能的話沒有媒體查詢。它會要求每個小屏幕尺寸的媒體查詢。 – Johnyb
請分享演示,以便我們檢查是否有媒體查詢可能。謝謝 –