gpt4 book ai didi

css - 让全屏 HTML5 视频背景模糊工作?

转载 作者:太空狗 更新时间:2023-10-29 13:49:29 25 4
gpt4 key购买 nike

我似乎已经尝试了本书中的所有技巧,但没有任何效果。

我有一个全屏、绝对定位的 HTML5 视频背景,我需要对其进行模糊处理。但是,我希望它有锋利的边缘。

到目前为止,我已经在网上尝试了大约 20 或 30 种不同的解决方案,但似乎没有任何效果。

这是我尝试过的:

-设置负边距

-设置负的上、左、右、下边距

-在 overflow hidden 的容器中设置正边距

-设置在 overflow hidden 的容器中

-此处记录的方法:Defined Edges With CSS3 Filter Blur - Defined Edges With CSS3 Filter Blur - CSS blur and retain sharp edges using absolute div - Blur absolute background whilst retaining solid edges - http://volkerotto.net/2014/07/03/css-background-image-blur-without-blury-edges/

这是目前的代码:

HTML

<video id="videobcg" preload="auto" autoplay="true" loop="loop"     muted="muted" volume="0">
<source src="vid/myVid.mp4" type="video/mp4">
<source src="vid/myVid.webm" type="video/webm">
Sorry, your browser does not support HTML5 video.
</video>

CSS

#videobcg {
position: absolute;
top: 0;
left: 0;
min-width: 100% !important;
max-height: 100% !important;
z-index: -1000;
overflow: hidden;
object-fit: fill;
-webkit-filter: blur(15px);
-moz-filter: blur(15px);
-o-filter: blur(15px);
-ms-filter: blur(15px);
filter: blur(15px);
}

也许我做错了什么,我不太确定。我正在做的事情是否阻止了它的工作?

在此先感谢您的帮助!

最佳答案

You might want to make that video bigger than the parent and center it inside it, I think that would get rid of that white blur inside the borders of the parent.

@Ashugeo,我采用了你的代码并按照你多年前的建议做了,它似乎有效。

Unfortunately, this doesn't seem to work. I also tried making the video even bigger and centering it, still doesn't seem to work.

@Finn C,如今它似乎可以使用转换: https://jsfiddle.net/Erik_J/6f483wm9/

HTML

<div id="container">
<video id="videobcg" preload="auto" autoplay="true" loop="loop" muted="muted" volume="0">
<source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4">
Sorry, your browser does not support HTML5 video.
</video>
</div>

CSS

body{ margin:0;}

#container {
width: 100vw;
height: 100vh;
text-align: center;
overflow: hidden;
}
#videobcg {
width: inherit;
height: inherit;
-o-filter: blur(15px);
filter: blur(15px);
object-fit: cover;
transform: scale(1.04);
}

关于css - 让全屏 HTML5 视频背景模糊工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32288848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com