简体   繁体   English

如何使用CSS,HTML在Wordpress上的图像(链接)上覆盖文本

[英]how to overlay text on image(linked) for wordpress using css, html

I am making my shopping website with wordpress. 我正在用wordpress制作购物网站。 Now I am making front page. 现在,我正在制作首页。 I want to put some image on the page which is linked to product detail page(or any other page i want). 我想在链接到产品详细信息页面(或我想要的任何其他页面)的页面上放置一些图像。

The main question is... I want to overlay some text on image which is responsive just as the image. 主要问题是...我想在图像上覆盖一些与图像一样敏感的文本。 I found a lot of answers for text-image overlay. 我发现了很多有关文本图像覆盖的答案。 However, it were not helpful because I need to add some text on 'linked' image, and I want to make the whole image area are clickable include the added text. 但是,这没有帮助,因为我需要在“链接的”图像上添加一些文本,并且我想使整个图像区域都可单击,包括添加的文本。

Every solution should be responsive one of course. 每个解决方案都应该是响应式的。

The below example is exactly what I want: http://www.glasses.com/ 下面的示例正是我想要的: http : //www.glasses.com/

在此处输入图片说明

A very clean solution for your problem, with 4 kind of text-overlay positioning. 一种非常干净的解决方案,带有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 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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM