如果你在一個元素包裹img
,您可以使用::before/::after
僞類,可以使用rgba()
半透明的覆蓋,並利用具有background-color
和transform: rotate()
定位,以創建傾斜傾斜,固體覆蓋。
* {margin:0;padding:0;box-sizing:border-box;}
.imgContainer {
width: 50%;
margin: auto;
overflow: hidden;
position: relative;
}
.imgContainer::after, .imgContainer::before {
content: '';
position: absolute;
}
.imgContainer::after {
top: 0; left: 0; bottom: 0; right: 0;
background: rgba(255,255,255,0.5);
}
.imgContainer::before {
height: 200%;
width: 50%;
background: #fff;
left: 0;
transform: translate(-40%,-50%) rotate(15deg);
}
img {
max-width: 100%;
}
.text {
position: absolute;
top: 50%; left: 50%;
width: 80%; height: 80%;
transform: translate(-50%,-50%);
background: rgba(255,255,255,.3);
z-index: 1;
padding: .5em;
}
<div class="imgContainer">
<img src="http://cdn.thedailybeast.com/content/dailybeast/articles/2015/03/31/neil-degrasse-tyson-defends-scientology-and-the-bush-administration-s-science-record/jcr:content/image.img.2000.jpg/1432067001553.cached.jpg" alt="alt">
<div class="text">
text text text text text text text text text text text text text text text text text text text text text text text text text text text text
</div>
</div>
你用白色十歲上下疊加變淡的IMG是什麼意思?或左側傾斜的白色蓋子? –
傾斜的部分。如果我可以更換圖像,並且仍然沒有必要操縱PS中的圖像,那將是理想的。有50個圖像需要添加到網站的其他部分,具有相同的確切樣式。 – ajwerth
我正在研究它,並做了覆蓋,但可以把它關閉。喜歡這個? https://codepen.io/anon/pen/LLjJzW –