我在下面創建了以下橫幅,使用三角形和矩形爲了在圖像上創建所需橫幅。但是,如果用戶在瀏覽器中放大這兩個容器之間的差距。任何想法如何我可以將兩個容器固定在一起,或者有更好的方法來使用CSS編寫此橫幅廣告?提前致謝! :)修復瀏覽器上的容器縮放和調整大小
代碼:
<html>
<style>
#triangle {
width: 0;
height: 0;
border-bottom: 150px solid red;
border-right: 50px solid transparent;
top: 8px;
position: relative;
}
#square {
background-color:red;
height:150px;
width:300px;
z-index: 3;
margin-left: 8px;
top: 8px;
position: relative;
color: white;
}
.align div {
display:inline-block;
float: left;
}
</style>
<div class="img">
<img src="IMAGE HERE" alt="test" width="800" height="150">
</div>
<div class="align">
<div id="square">
<h1>
Headline
</h1>
<p>
Some text here!
</p>
</div>
<div id="triangle"></div>
</div>
</html>
你的html在哪裏? –
對不起,我的錯誤。 HTML添加:) – Andrew
用JSFiddle查看代碼時我看不到任何差距 – Relisora