html - CSS 使图像上的文本更具可读性

标签 html css overlay

我现在正在处理一些事情,但这行不通!

基本上我想做的是在我的图像上放一个黑色不透明的“屏幕”,这样它就不那么亮了,你可以阅读图像顶部的文字。

这里的例子:

enter image description here

这是我目前拥有的。

<div class="overlay">
    <span class="front-coffee block"></span>
    <p class="center">Coffee Shop</p>
</div>

div.overlay{background: black; z-index: 5; width:100%; height:100%;}
.block { display: block; }
div.popularCategory p{font-size: 24pt; color: white; margin-top:-50px}
span.front-coffee{background:url('../img/categories/coffee.jpg') no-repeat center; zoom:0.65; width:100%; height:100%; z-index: 4}

最佳答案

如果我没听错,那么您可以尝试稍微模糊一下照片,使文本不会显示给用户,但是这种方法和您的方法也可能会通过 Firebug 或任何其他类似的东西进行更改,并使用户可见的文本,因此这有点不安全。我认为解决此问题的最佳方法是手动编辑照片并添加叠加层,这样就没人能看到原始图像了。

下面是模糊照片的方法(Cross Browser Image Blur with CSS):

img {
    width:367;
    height:459px;
    -webkit-filter: blur(3px); //change the value according to what suits the best
    -moz-filter: blur(3px); //change the value according to what suits the best
    -o-filter: blur(3px); //change the value according to what suits the best
    -ms-filter: blur(3px); //change the value according to what suits the best
    filter: blur(3px); //change the value according to what suits the best
}

关于html - CSS 使图像上的文本更具可读性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19335894/

相关文章:

Android 强制关闭 GoogleMap 应用程序中的 NullPointerException

jquery - 如何使用 jQuery 将鼠标悬停在 div 上时显示覆盖 div?

javascript - 在动态单选按钮中仅选择一个

javascript - 使用日语 tategaki 时对齐 block 元素 (p, div) 的最后一行(书写模式 : tb-rl)

javascript - LazyLaoding CSS 背景(不是 HTML <img> 标签)

html - CSS 百分比宽度不起作用

html - 如何在重组文本中注释字符串?

javascript - 链接悬停故障 - 基本 UL 链接使页面在悬停时跳转?

javascript - Canvas 文本调整大小

jquery - Colorbox不会显示控件、边框