我已經放在我的網站一些文字上的圖像的頂部,它看起來像這樣:HTML/CSS將文字放在圖像上而不溢出?
現在我希望它看起來像這樣:
所以,切斷「y」的下半部分。我目前的HTML/CSS是:
.header {
width: 100%;
white-space: nowrap;
}
.header img {
width: 100%;
background-color: #575757;
box-shadow: 0.000em 0.188em 0.188em #999999;
position: relative;
left: 0;
}
.header span {
font-size: 4.938em;
color: #f8f8f8;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
margin: 0;
text-shadow: 0 0 0.05em #999999;
/*place it over heading image*/
vertical-align: baseline;
position: relative;
top: 0;
width: 0;
display: inline-block;
overflow: visible;
z-index: 100;
}
<div class="header">
<span>Systems</span><!-- no whitespace
--><img src="http://lorempixel.com/400/100/" />
</div>
我怎樣才能使這樣的圖像之外的任何文本切斷?
使用溢出:隱藏,並給一些固定的高度.header類。然後把高度:100%的圖像,即.header img – yogihosting
這個https://jsfiddle.net/Lg0wyt9u/107/怎麼樣? –