【问题标题】:Suggestions on making the text more visible or readable关于使文本更可见或更易读的建议
【发布时间】:2017-10-04 14:08:16
【问题描述】:

我的网站上有这张照片,看起来像这样:

我尝试在文本上添加阴影,它看起来像这样:

问题是阴影看起来有点奇怪。

关于如何在不改变文本和背景的颜色的情况下使其更具可读性的任何建议?

【问题讨论】:

  • 将文本更改为白色并在图像上放置滤镜或保持文本颜色相同并为文本提供浅色背景以进行对比。
  • 给文本一个背景色?
  • @ovokuro 你是什么意思?

标签: html css text background photo


【解决方案1】:

您可以尝试使用全方位的文字阴影:

.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>

通过以上方式,您可以更改阴影的不透明度以使其更加突出/不那么突出

【讨论】:

  • 我想我可以用这个,谢谢老兄
【解决方案2】:

这个答案假设您的标记是这样的:

.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>

【讨论】:

    【解决方案3】:

    您可以通过添加以下内容为文本添加白色笔触:

    -webkit-text-stroke: 1px white;
    

    或者如果可以的话,添加一个半透明的背景

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-20
    • 2020-11-07
    • 2017-03-27
    • 2020-04-14
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多