我試圖刪除解決此圖像自動生成的容器保證金自動生成的HTML容器保證金。以下是我用來製作它的代碼。您可以查看網站here。我試圖添加一個margin and padding item to the body element,但它沒有解決問題。如何刪除圖像周圍
.container {
position: relative;
width: 240px;
height: 240px;
}
.image {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.container:hover .overlay {
opacity: 0.85;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
}
<div class="container">
<img src="./img/headshots/Exec_DMoon.jpg" width="240" height="240" alt="Photo of David Moon, Assistant Vice President for Financial Affairs" class="image">
<div class="overlay">
<div class="text"><b>David Moon</b> Assistant Vice President for Financial Affairs, <a class="usa-external_link" target="_blank" href="mailto:[email protected]">Email</a></div>
</div>
</div>
這是所需的輸出:
我在做什麼錯?
我缺少的東西?您鏈接的網站看起來像「所需的輸出」。另外您網站上的代碼不符合您的代碼 – j08691
給[flexboxes(https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes)一展身手的截圖,將節省你有些頭疼。 – Amous
@ j08691對不起,我只是同步我的代碼到GitHub的頁面,現在它顯示爲我描述。 – jamesharnett