嘗試將圖片上的鼠標懸停在圖片上方,其中不透明的疊加層顯示在單詞上,但有點麻煩。將文本的位置移動到html中的框中
我的代碼如下:
<style type="text/css">
a.hovertext {
position: relative;
width: 220px;
text-decoration: none !important;
text-align: center;
}
a.hovertext:after {
content: attr(data-title);
position: absolute;
left: 0;
bottom: 5px;
padding: 0em 0px;
width: 220px;
height: 220px;
background: rgba(0,0,0,0.8);
text-decoration: none !important;
color: #fff;
opacity: 0;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
-o-transition: 0.5s;
-ms-transition: 0.5s;
}
a.hovertext:hover:after, a.hovertext:focus:after {
opacity: 1.0;
}
</style>
<a class="hovertext" data-title="Europe 2014" href="URL"><img alt="" border="0" src="URL" height="220" width="220" /></a>
的想法是我怎麼想,但我無法弄清楚如何將文本移動到盒子的中間垂直,這樣它完全居中,以及如何更改字體的大小和樣式。
任何想法?我相信這是一個簡單的修改,但我不擅長html。
用這種方法,也當改變寬度或高度的框中,文字將永遠在它的中間! – Mark