请查看以下小提琴:https://jsfiddle.net/xnr7tqm1/
我有这个HTML标记:
<div class="media-container">
<iframe width="365" height="200" src="https://www.youtube.com/embed/JqjIb6FhU_k" frameborder="0" allowfullscreen></iframe>
</div>
使用以下css:
.media-container {
position: fixed;
right: 28px;
bottom: 77px;
width: 340px;
height: 200px;
border-radius: 7px 7px 0 0;
overflow: hidden;
text-align: center;
iframe {
margin-left: -16px;
}
}
.media-container:after, .media-container:before {
bottom: 0%;
left: 0%;
border: solid transparent;
content: " ";
height: 0;
width: 164px;
position: absolute;
pointer-events: none;
}
.media-container:after {
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #fff;
border-width: 16px;
margin-left: -16px;
}
.media-container:before {
border-color: rgba(245, 41, 34, 0);
border-bottom-color: #fff;
border-width: 16px;
margin-left: 175px;
}
我想在视频的底部也有圆角,就像在顶部一样。问题是我使用伪元素在底部绘制箭头,我很难在这个设置中围绕底角。
任何人都知道如何解决这个问题?
谢谢!
答案 0 :(得分:2)
通过添加另一个元素并使用框阴影,您可以创建背景颜色的“反边框”,屏蔽您的视频。请参阅下面的元素“.bottom-borders”:
.media-container {
position: relative;
width: 340px;
height: 200px;
border-radius: 7px 7px 0 0;
overflow: hidden;
text-align: center;
}
iframe {
margin-left: -16px;
}
.media-container:after, .media-container:before {
bottom: 0%;
left: 0%;
border: solid transparent;
content:" ";
height: 0;
width: 164px;
position: absolute;
pointer-events: none;
}
.media-container:after {
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #fff;
border-width: 16px;
margin-left: -16px;
}
.media-container:before {
border-color: rgba(245, 41, 34, 0);
border-bottom-color: #fff;
border-width: 16px;
margin-left: 175px;
}
.bottom-borders {
height: 7px;
position: absolute;
bottom: 16px;
width: 100%;
}
.bottom-borders:before,
.bottom-borders:after {
content: "";
position: absolute;
top: 0;
width: 7px;
height: 7px;
}
.bottom-borders:before {
left: 0;
border-bottom-left-radius: 7px;
box-shadow: -3.5px 3.5px 0 3.5px white;
}
.bottom-borders:after {
right: 0;
border-bottom-right-radius: 7px;
box-shadow: 3.5px 3.5px 0 3.5px white;
}
<div class="media-container">
<iframe width="365" height="200" src="https://www.youtube.com/embed/JqjIb6FhU_k" frameborder="0" allowfullscreen></iframe>
<div class="bottom-borders"></div>
</div>
答案 1 :(得分:1)
我坚持使用一个伪元素的阴影和另一个伪元素的渐变 - 不需要那种额外的真实元素。 这是小提琴:https://jsfiddle.net/gb8h983r/1/
.media-container {
position: relative;
width: 340px;
height: 200px;
overflow: hidden;
border-radius: 7px 7px 0 0;
}
.media-container iframe {
width: 110%;
height: 110%;
margin-left: -5%;
}
.media-container:after, .media-container:before {
content: "";
position: absolute;
pointer-events: none;
}
.media-container:after {
right: 0;
left: 0;
bottom: 16px;
height: 14px;
border-radius: 7px;
box-shadow: -333px 7px #ffffff, 333px 7px #ffffff;
/* 333px = 340px -7px */
}
.media-container:before {
right: 0;
bottom: 0;
left: 0;
height: 16px;
background:
linear-gradient(45deg, rgba(255,255,255,1) 0%, rgba(255,255,255,1) 49.99%, rgba(255,255,255,0) 50%, rgba(255,0,0,0) 100%) -8px 100%,
linear-gradient(135deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 49.99%, rgba(255,255,255,1) 50%, rgba(255,255,255,1) 100%) 8px 100%;
/* 8px = 16px / 2 */
background-repeat: no-repeat;
}
答案 2 :(得分:0)
我认为通过蒙版图像覆盖视频会更容易。像这样:
img {
width: 340px;
height: 200px;
position: absolute;
z-index: 2;
/*right: 28px;
bottom: 77px;*/
}
.media-container {
position: fixed;
z-index: 1;
right: 28px;
bottom: 77px;
width: 340px;
height: 200px;
overflow: hidden;
text-align: center;
}
&#13;
<img src="http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg">
<div class="media-container">
<iframe width="365" height="200" src="https://www.youtube.com/embed/JqjIb6FhU_k" frameborder="0" allowfullscreen wmode="Opaque"></iframe>
<div>
&#13;
但是想象一下这张图片是专门绘制PNG的,以覆盖0不透明度的视频。
答案 3 :(得分:0)
这样做:
<div class="fixed">
<div class="media-container">
<iframe width="340" height="200" src="https://www.youtube.com/embed/JqjIb6FhU_k" frameborder="0" allowfullscreen></iframe>
</div>
</div>
的CSS:
.fixed{
position:fixed;
right: 28px;
bottom: 77px;
width: 340px;
height: 200px;
}
.media-container {
position: relative;
border-radius: 7px;
text-align: center;
background: #ddd;
width:340px;
}
.media-container:after {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0, 0, 0, 0);
border-top-color: #ddd;
border-width: 30px;
margin-left: -30px;
}