2016-09-26 59 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?也許我會看看這個 –

相關問題