2016-11-08 37 views
0

当不使用相对,绝对或固定位置放大和缩小页面时,我需要让所有ID不移动。当我放大和缩小但没有ID时,我得到了外部的字母和数字框。在不使用位置元素的情况下在CSS中定位

.outer { 
margin: auto; 
border: 20px outset orange; 
width: 80%; 
overflow: auto; 
} 

.letters { 
border: 10px solid red; 
float: left; 
width: 50%; 
box-sizing: border-box; 
} 

.numbers { 
border: 10px solid blue; 
float: right; 
width: 50%; 
box-sizing: border-box; 
clear: auto 
} 


#one { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: palegoldenrod; 
text-align: center; 
} 

#two { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: salmon; 
text-align: center; 
margin-left: 120px; 
} 

#three { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: greenyellow; 
text-align: center; 
margin-left: 240px; 
} 

#four { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: plum; 
text-align: center; 
margin-left: 120px; 
} 

#five { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: thistle; 
text-align: center; 
} 

#oneA { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: palegoldenrod; 
text-align: center; 
float: right; 
} 

#twoA { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: salmon; 
text-align: center; 
float: right; 
margin-top: 120px; 
} 

#threeA { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: greenyellow; 
text-align: center; 
float: right; 
margin-top: 240px; 
} 

#fourA { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: plum; 
text-align: center; 
margin-left: 502px; 
margin-right: 120px; 
float: right; 
} 

#fiveA { 
width: 100px; 
height: 100px; 
border: 10px dashed aqua; 
background-color: thistle; 
text-align: center; 
margin-left: 622px; 
float: right; 
} 
+2

你的问题没有得到清除 –

+0

我不能在CSS中使用任何位置元素,一切都需要留在正确的位置,你使用鼠标滚轮来放大和缩小的页面 –

+0

缩放在不同的浏览器/平台上无法预测。我真的不知道如何在不使用'position'属性的情况下做到这一点......在这种情况下,我也没有看到使用'position:relative'的问题,因为所有东西都会按照正确的顺序排列你的'float:right'规则? – Toastrackenigma

回答

0

是否有任何要移动的元素?如果没有,我会建议禁用变焦:

<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' /> 
相关问题