答案 0 :(得分:2)
您可以尝试使用全方位文字阴影:
.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>
&#13;
通过上述内容,您可以更改阴影的不透明度,使其更加突出显示
答案 1 :(得分:1)
您可以通过添加以下内容为文本添加白色笔划:
-webkit-text-stroke: 1px white;
或者,如果可以,添加半透明背景
答案 2 :(得分:1)
这个答案假设您的标记是这样的:
.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>