【问题标题】:how to overlay text on image(linked) for wordpress using css, html如何使用css,html在wordpress的图像(链接)上覆盖文本
【发布时间】:2017-11-20 05:55:59
【问题描述】:

我正在使用 wordpress 制作我的购物网站。 现在我正在制作头版。我想在链接到产品详细信息页面(或我想要的任何其他页面)的页面上放置一些图像。

主要问题是... 我想在图像上覆盖一些与图像一样响应的文本。我找到了很多关于文本图像叠加的答案。但是,它没有帮助,因为我需要在“链接”图像上添加一些文本,并且我想让整个图像区域都可以点击,包括添加的文本。

当然,每个解决方案都应该是响应式的。

下面的例子正是我想要的: http://www.glasses.com/

【问题讨论】:

  • SO 当然已经有了答案。你搜索过SO吗?不要搜索“text-image overlay”,而是搜索“center text on image”。

标签: html css wordpress image overlay


【解决方案1】:

为您的问题提供了一个非常干净的解决方案,具有 4 种文本叠加定位。

<div class="module top">
  <h2>Skyscrapers</h2>
</div>

<div class="module mid">
  <h2>Skyscrapers</h2>
</div>

<br style="clear: both;">

<div class="module cap">
  <p>Skyscraper are really neat and stuff because they are tall.</p>
</div>

<div class="module lr">
  <p>Skyscrapers sometimes have nicknames like jim or shim.</p>
</div>

css

@import url(https://fonts.googleapis.com/css?family=Roboto:400,900);

.module {
  background: 
    linear-gradient(
      rgba(0, 0, 0, 0.6),
      rgba(0, 0, 0, 0.6)
    ),
    url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/skyscrapers.jpg);
  background-size: cover;
  width: 300px;
  height: 200px;
  margin: 10px 0 0 10px;
  position: relative;
  float: left;
}
.module:hover{
  background: rgba(1,222,123,0.3);
}
.top h2 {
  color: white;
  margin: 0;
  padding: 20px;
}

.lr p {
  font-family: 'Roboto', sans-serif;
  position: absolute;
  bottom: 20px;
  left: 20px;
  color: white;
  margin: 0;
}

.mid h2 {
  font-family: 'Roboto', sans-serif;
  font-weight: 900;
  color: white;
  text-transform: uppercase;
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 2rem;
  transform: translate(-50%, -50%);
}

.cap p {
  padding: 20px;
  color: white;
  font: 12px Monaco, Mono-Space;
  margin: 0;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-25
    • 2020-07-19
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多