【发布时间】:2017-10-04 14:08:16
【问题描述】:
【问题讨论】:
-
将文本更改为白色并在图像上放置滤镜或保持文本颜色相同并为文本提供浅色背景以进行对比。
-
给文本一个背景色?
-
@ovokuro 你是什么意思?
标签: html css text background photo
【问题讨论】:
标签: html css text background photo
您可以尝试使用全方位的文字阴影:
.text {
padding:5px;
background: black;
font-size: 20px;
text-shadow: -1px -1px 0 rgba(255, 255, 255, 0.5), 1px -1px 0 rgba(255, 255, 255, 0.5), -1px 1px 0 rgba(255, 255, 255, 0.5), 1px 1px 0 rgba(255, 255, 255, 0.5);
}
<div class="text">some test text</div>
通过以上方式,您可以更改阴影的不透明度以使其更加突出/不那么突出
【讨论】:
这个答案假设您的标记是这样的:
.container {
position: relative;
}
p {
position: absolute;
bottom: 0;
padding: 2em;
font-size: 1.5em;
}
<div class="container">
<img src="https://unsplash.it/300/300">
<p>Some text</p>
</div>
您可以尝试以下几种方法:
为文本添加背景...
.container {
position: relative;
}
p {
position: absolute;
bottom: 0;
padding: 2em;
font-size: 1.5em;
background: #ccc;
}
<div class="container">
<img src="https://unsplash.it/300/300">
<p>Some text</p>
</div>
在文本后面添加一个微妙的渐变...
.container {
position: relative;
display: inline-block;
}
.container:after {
content: '';
position: absolute;
top: 50%;
bottom: 0;
left: 0;
right: 0;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(255, 255, 255, .6));
}
p {
position: absolute;
bottom: 0;
padding: 2em;
font-size: 1.5em;
z-index: 3;
}
<div class="container">
<img src="https://unsplash.it/300/300">
<p>Some text</p>
</div>
添加文字阴影...
.container {
position: relative;
}
p {
position: absolute;
bottom: 0;
padding: 2em;
font-size: 1.5em;
text-shadow: 0px 0px 5px #ffffff;
}
<div class="container">
<img src="https://unsplash.it/300/300">
<p>Some text</p>
</div>
更大的字体、额外的粗细、大写...
.container {
position: relative;
}
p {
position: absolute;
bottom: 0;
padding: .5em;
font-size: 2em;
text-transform: uppercase;
font-weight: bold;
}
<div class="container">
<img src="https://unsplash.it/300/300">
<p>Some text</p>
</div>
覆盖在不透明文本后面...
.container {
position: relative;
display: inline-block;
}
p:before {
content: '';
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.5);
z-index: -1;
}
p {
position: absolute;
bottom: 0;
padding: 1em 2em;
font-size: 1.5em;
left: 0;
right: 0;
z-index: 1;
}
<div class="container">
<img src="https://unsplash.it/300/300">
<p>Some text</p>
</div>
【讨论】:
您可以通过添加以下内容为文本添加白色笔触:
-webkit-text-stroke: 1px white;
或者如果可以的话,添加一个半透明的背景
【讨论】: