目录

操作方法 - 带有透明文本的图片


了解如何使用 CSS 创建具有透明(透视)背景文本的图片。


透明图片文本

Norway

标题

Lorem ipsum dolor sat amet,他的 etiam torquatos。Tollit solat phaedrum te duo, eum cu recteque expetendis neglegentur。 Cu mentitum maiestatis persequeris pro, pri ponderum trapatos ei.

亲自试一试 »

如何创建透明图片文本

步骤1)添加HTML:

示例

<div class="container">
  <img src="notebook.jpg" alt="Notebook" style="width:100%;">
  <div class="content">
    <h1>Heading</h1>
    <p>Lorem ipsum..</p>
  </div>
</div>

步骤2)添加CSS:

示例

.container {
  position: relative;
  max-width: 800px; /* Maximum width */
  margin: 0 auto; /* Center it */
}

.container .content {
  position: absolute; /* Position the background text */
  bottom: 0; /* At the bottom. Use top:0 to append it to the top */
  background: rgb(0, 0, 0); /* Fallback color */
  background: rgba(0, 0, 0, 0.5); /* Black background with 0.5 opacity */
  color: #f1f1f1; /* Grey text */
  width: 100%; /* Full width */
  padding: 20px; /* Some padding */
}
亲自试一试 »