2016-09-26 57 views

回答

1

您可以使用@media CSS更改特定屏幕尺寸的元素类的大小(宽度,高度,顶部,底部等)的值。

@media only screen and (max-width:1100px) { 
    .yourClass {yourStyle: style} 
    .otherClass {yourStyle: style} 
} 
@media only screen and (max-width:570px) { 
    .yourClass {yourStyle: style} 
    .otherClass {yourStyle: style} 
} 
+1

此外,您还可以使用VW和VH单位指定内部的div的测量与视规模:HTTPS: //snook.ca/archives/html_and_css/vm-vh-units –

0

根据你的问题,你可以使用宽度:“calc”css技巧来修复宽度;这将使自动响应运行该片段。下面是现场小提琴也fiddleLiveDemo

.container{ 
 
    height:100px; 
 
    position:relative; 
 
    border:1px solid red; 
 
} 
 
.div1{ 
 
    border:1px solid blue; 
 
    background:#bbb; 
 
    position: absolute; 
 
    left: 40px; 
 
    width: calc(100% - 80px);/* 40px gap between both sides of the div and the edges of the window */ 
 
    height:80px; 
 
    margin-top:10px; 
 
} 
 
.div2{ 
 
    border:1px solid yellow; 
 
    background:red; 
 
    position:fixed; 
 
    left: 60px; 
 
    width: calc(100% - 120px); /* 60px gap between both sides of the div and the edges of the window */ 
 
    height:70px; 
 
    margin-top:5px; 
 
} 
 

 
<div class="container"> 
 
<div class="div1"> 
 
    <div class="div2"> 
 

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

+0

嗨,这一切都有道理,但我似乎无法使它与我有的代码一起工作 - 这是我工作的网站http:// datahealthcheck.databarracks.com/2016_NA/#title-page,这是svg /图表,我试图将此应用于 –

+0

哪部分你喜欢这些div?也许我会看看这个 –

相关问题