html - 图像 Bootstrap 上的徽章

标签 html css twitter-bootstrap

我必须像下面的示例图片一样在图像上放置徽章。我对 css 有不好的经验,所以如果有人能帮助我,我将不胜感激。

.product {
  margin: 0 30px 30px 0;
  width: 360px;
  position: relative;
  float: left;
}
.image-product {
  position: relative;
  width: 100%;
  height: 360px;
  overflow: hidden;
  border: solid;
  border-width: 1px;
}
.image-product > a,
.image-product img {
  display: block;
  width: 100%;
  height: 100%;
}
<div class="product clearfix">
  <div class="image-product">
    <a href="#">
      <img src="http://richthediabetic.com/wp-content/uploads/2013/07/Pizza.jpg" />
    </a>
  </div>
</div>

enter image description here

最佳答案

在图片上方添​​加徽章的 img 标签

<div class="product clearfix">    
    <div class="image-product">
        <a href="#">
            <img class="badgeOne" src="http://richthediabetic.com/wp-content/uploads/2013/07/Pizza.jpg" />
            <img src="http://richthediabetic.com/wp-content/uploads/2013/07/Pizza.jpg" />
        </a>
    </div>
</div>

像这样将 badgeOne 类添加到 css

.product {
  margin: 0 30px 30px 0;
  width: 360px;
  position: relative;
  float: left;
}
.image-product {
  position: relative;
  width: 100%;
  height: 360px;
  overflow: hidden;
  border: solid;
  border-width: 1px;
}
.image-product > a,
.image-product img {
  display: block;
  width: 100%;
  height: 100%;
}

.badgeOne {position: absolute;
    top: 10px;
    right: 10px;
    width: 20px !important;
    height: 20px !important;
    border: 1px solid;}

根据您的需要使用它...

这是一个示例 Fiddle

关于html - 图像 Bootstrap 上的徽章,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33033214/

相关文章:

css - Bootstrap 3 绝对行

css - Asset Pipeline undefined variable SASS

html - 调整 Bootstrap Jumbotron 的大小以适合背景图像

javascript - 如何获得隐藏图像的高度?

html - 无法让 Twitter Bootstrap 导航栏工作?

javascript - 如何跟踪网站中图像的下载次数

html - Flexbox 将一个元素居中对齐,另一个元素在页面底部对齐

html - 两列布局 - 如果左列宽度太小,则将右列移至下一行

html - 尝试使用类似于此的 HTML 和 CSS 对网格进行编码

jquery - 使用 jQuery 获取百分比 CSS 位置