代码之家  ›  专栏  ›  技术社区  ›  MK-DK

将H标记放在引导按钮上

  •  0
  • MK-DK  · 技术社区  · 7 年前

    我正在使用引导程序3.3.7。我想把我的头条新闻放在小型和大型设备上。我尝试使用默认的引导程序类来定位按钮。但我不能在头条上报道这件事。我希望尽可能多地使用引导类,所以我不必自定义和覆盖引导类。

    如何定位标题,如下图所示?

    There is a demo of the grid here

    */
    身体{
    背景色:f5f5f5;
    }
    div {
    背景色:fff;
    }
    .索引内容A:悬停{
    颜色:黑色;
    文字装饰:无;
    }
    .索引内容.行{
    上边距:20px;
    }
    .索引内容A{
    颜色:黑色;
    }
    .索引内容.card{
    背景色:ffffff;
    填充:0;
    -WebKit边框半径:4px;
    -Moz边界半径:4px;
    边界半径:4px;
    盒影:0 4px 5px 0 rgba(0,0,0,0.14),0 1px 10px 0 rgba(0,0,0,0.12),0 2px 4px-1px rgba(0,0,0,0.3);
    }
    .索引内容.卡:悬停{
    盒影:0 16px 24px 2px rgba(0,0,0,0.14),0 6px 30px 5px rgba(0,0,0,0.12),0 8px 10px-5px rgba(0,0,0,0.3);
    颜色:黑色;
    }
    .索引内容.card img{
    宽度:100%;
    边框左上半径:4px;
    边框右上半径:4px;
    高度:350px;
    }
    .索引内容.卡H4{
    裕度:20px;
    }
    .索引内容.卡P{
    裕度:20px;
    不透明度:0.65;
    }
    .索引内容.蓝色按钮{
    宽度:100px;
    -WebKit转换:背景色1s,颜色1s;
    /*对于Safari 3.1至6.0*/
    过渡:背景色0.5s,颜色0.5s;
    最小高度:20px;
    背景色:4caf50;
    颜色:ffffff;
    边界半径:4px;
    文本对齐:居中;
    字体粗细:较轻;
    页边:0px 20px 15px 20px;
    衬垫:5px 0px;
    显示:内联块;
    }
    .索引内容.蓝色按钮:悬停{
    背景色:
    颜色:002E5b;
    }
    /*设置块元素之间的宽度*/
    .小填充.top{
    填充顶部:10px;
    }
    
    .小填充.bottom{
    垫底:10px;
    }
    .小填充。左{
    左侧填充:5px;
    }
    
    .小填充。右{
    右侧填充:5px;
    }
    
    .row[class*=“列-”]{
    左侧填充:5px;
    右侧填充:5px;
    }
    
    /*设置列的全宽*/
    @介质(最大宽度:768px){
    .img响应{
    宽度:100%;
    }
    }
    
    /*网格元素媒体查询*/
    @介质(最小宽度:768px){
    .卡片{
    职位:相对;
    }
    .卡片内容{
    位置:绝对;
    底部:0;
    宽度:100%;
    背景:rgba(0,0,0,0.5);
    }
    .卡内容h4,
    .卡片内容P{
    颜色:白色;
    宽度:100%;
    浮动:左;
    裕度:0 0 5px;
    }
    .卡内容A{
    浮动:右;
    }
    .索引内容.卡H4,
    .索引内容.卡P{
    填料:15px 20px;
    边距:0;
    }
    .索引内容.卡P{
    填料:0 20px 15px;
    边距:0;
    }
    }
    .页边距\底部{
    底部边缘:10px;
    }
    .row[class*=“列-”]{
    右侧填充:5px;
    左侧填充:5px;
    }
    行{
    左边距:-5px;
    右边距:-5px;
    }
    .卡img底部{
    颜色:fff;
    高度:20rem;
    背景:url(images/img1.jpg)center no repeat;
    背景尺寸:封面;
    }
    .img响应{
    高度:100%;
    }
    /*按钮位置*/
    .居中{
    位置:绝对;
    顶部:50%;
    左:50%;
    转换:转换(-50%,-50%);
    }
    
    .右下角{
    位置:绝对;
    底部:8px;
    右:16px;
    }
    
    .左下角{
    位置:绝对;
    底部:8px;
    左:16px;
    }
    
    
    
    &!--列1-1-2-->
    <DIV class=“row”>
    <DIV class=“col-sm-3页边距\u bottom”>
    <img src=“http://placehold.it/300x410”alt=“5”class=“img responsive”></img>
    <h3 class=“centered”>标题</h3>
    <button class=“btn btn default centered”style=“background color:transparent;border:2px solid black;”>请参阅产品</button>
    </DIV>
    <DIV class=“col-sm-6页边距\u bottom”>
    <img src=“http://placehold.it/600x410”alt=“5”class=“img responsive”/>
    <H3 class=“Bottom Left”>标题</H3>
    <button class=“btn btn success bottom right”>请参阅优惠</button>
    &!--<I class=“fa fa long arrow right”></A>-->
    </DIV>
    <DIV class=“col-sm-3”>
    <DIV class=“row”>
    <DIV class=“col-xs-6 col-sm-12页边距\u bottom”>
    <img src=“http://placehold.it/300x200”alt=“5”class=“img responsive”/>gt;
    <h3 class=“centered”>标题</h3>
    <button class=“btn btn success centered”>请参阅优惠</button>
    &!--<I class=“fa fa long arrow right”></A>-->
    </DIV>
    <DIV class=“col-xs-6 col-sm-12页边距\u bottom”>
    <img src=“http://placehold.it/300x200”alt=“5”class=“img responsive”/>gt;
    <h3 class=“centered”>标题</h3>
    <button class=“btn btn success centered”>请参阅优惠</button>
    &!--<I class=“fa fa long arrow right”></A>-->
    </DIV>
    </DIV>
    </DIV>
    </DIV>
    
    
    </DIV>>=
    < / div用于定位按钮。但我不能在头条上报道这件事。我希望尽可能多地使用引导类,所以我不必自定义和覆盖引导类。

    如何定位标题,如下图所示?

    enter image description here

    There is a demo of the grid here .

      /* Card and Button */
    body {
      background-color: #f5f5f5;
    }
    div {
      background-color: #fff;
    }
    .index-content a:hover {
      color: black;
      text-decoration: none;
    }
    .index-content .row {
      margin-top: 20px;
    }
    .index-content a {
      color: black;
    }
    .index-content .card {
      background-color: #FFFFFF;
      padding: 0;
      -webkit-border-radius: 4px;
      -moz-border-radius: 4px;
      border-radius: 4px;
      box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    }
    .index-content .card:hover {
      box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.3);
      color: black;
    }
    .index-content .card img {
      width: 100%;
      border-top-left-radius: 4px;
      border-top-right-radius: 4px;
      height: 350px;
    }
    .index-content .card h4 {
      margin: 20px;
    }
    .index-content .card p {
      margin: 20px;
      opacity: 0.65;
    }
    .index-content .blue-button {
      width: 100px;
      -webkit-transition: background-color 1s, color 1s;
      /* For Safari 3.1 to 6.0 */
      transition: background-color 0.5s, color 0.5s;
      min-height: 20px;
      background-color: #4CAF50;
      color: #ffffff;
      border-radius: 4px;
      text-align: center;
      font-weight: lighter;
      margin: 0px 20px 15px 20px;
      padding: 5px 0px;
      display: inline-block;
    }
    .index-content .blue-button:hover {
      background-color: #dadada;
      color: #002E5B;
    }
    /* Set width between block elements */
        .small-padding.top {
           padding-top:10px;
        }
    
        .small-padding.bottom {
            padding-bottom:10px;
        } 
        .small-padding.left {
            padding-left:5px;
        }
    
        .small-padding.right {
            padding-right:5px;
        }
    
        .row [class*="col-"] {
          padding-left: 5px;
          padding-right: 5px;
        }
    
    /* Set full width on columns */
    @media (max-width: 768px) {
        .img-responsive {
        width: 100%;
        }
    }
    
    /* GRID ELEMENTS MEDIA QUERIES */
    @media (min-width: 768px) {
      .card {
        position: relative;
      }
      .card-content {
        position: absolute;
        bottom: 0;
        width: 100%;
        background: rgba(0, 0, 0, 0.5);
      }
      .card-content h4,
      .card-content p {
        color: white;
        width: 100%;
        float: left;
        margin: 0 0 5px;
      }
      .card-content a {
        float: right;
      }
      .index-content .card h4,
      .index-content .card p {
        padding: 15px 20px;
        margin: 0;
      }
      .index-content .card p {
        padding: 0 20px 15px;
        margin: 0;
      }
    }
    .margin_bottom {
      margin-bottom: 10px;
    }
    .row [class*="col-"] {
      padding-right: 5px;
      padding-left: 5px;
    }
    .row {
      margin-left: -5px;
      margin-right: -5px;
    }
    .card-img-bottom {
      color: #fff;
      height: 20rem;
      background: url(images/img1.jpg) center no-repeat;
      background-size: cover;
    }
    .img-responsive { 
        height: 100%;
    }
    /* Button Position */
    .centered {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    .bottom-right {
        position: absolute;
        bottom: 8px;
        right: 16px;
    }
    
    .bottom-left {
        position: absolute;
        bottom: 8px;
        left: 16px;
    }
    <div class="container">
        
            
       
        <!-- Col 1 - 1 - 2 -->
        <div class="row">
            <div class="col-sm-3 margin_bottom">
                <img src="http://placehold.it/300x410" alt="5" class="img-responsive"></img>
                <h3 class="centered">HEADLINE</h3>
                <button class="btn btn-default centered"style="background-color:transparent;border:2px solid black;">See Offer</button>
            </div>
            <div class="col-sm-6 margin_bottom">
                <img src="http://placehold.it/600x410" alt="5" class="img-responsive" />
                <h3 class="bottom-left">HEADLINE</h3>
                <button class="btn btn-success bottom-right">See Offer</button>
                <!--<i class="fa fa-long-arrow-right"></a>-->
            </div>
            <div class="col-sm-3">
                <div class="row">
                    <div class="col-xs-6 col-sm-12 margin_bottom">
                        <img src="http://placehold.it/300x200" alt="5" class="img-responsive" />
                        <h3 class="centered">HEADLINE</h3>
                        <button class="btn btn-success centered">See Offer</button>
                        <!--<i class="fa fa-long-arrow-right"></a>-->
                    </div>
                    <div class="col-xs-6 col-sm-12 margin_bottom">
                        <img src="http://placehold.it/300x200" alt="5" class="img-responsive" />
                        <h3 class="centered">HEADLINE</h3>
                        <button class="btn btn-success centered">See Offer</button>
                        <!--<i class="fa fa-long-arrow-right"></a>-->
                    </div>
                </div>
            </div>
        </div>
        
        
    </div>
    1 回复  |  直到 7 年前
        1
  •  1
  •   Turnip Moushumi Ahmed    7 年前

    我会把每个包起来 h3 及其伴随物 button 在一个 div 并使用它同时定位两个元素。

    如。

    <h3 class="centered">HEADLINE</h3>
    <button class="btn btn-default centered">See Offer</button>
    

    会变成

    <div class="centered">
        <h3>HEADLINE</h3>
        <button class="btn btn-default">See Offer</button>
    </div>
    

    /* Card and Button */
    body {
      background-color: #f5f5f5;
    }
    div {
      background-color: #fff;
    }
    .index-content a:hover {
      color: black;
      text-decoration: none;
    }
    .index-content .row {
      margin-top: 20px;
    }
    .index-content a {
      color: black;
    }
    .index-content .card {
      background-color: #FFFFFF;
      padding: 0;
      -webkit-border-radius: 4px;
      -moz-border-radius: 4px;
      border-radius: 4px;
      box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    }
    .index-content .card:hover {
      box-shadow: 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.3);
      color: black;
    }
    .index-content .card img {
      width: 100%;
      border-top-left-radius: 4px;
      border-top-right-radius: 4px;
      height: 350px;
    }
    .index-content .card h4 {
      margin: 20px;
    }
    .index-content .card p {
      margin: 20px;
      opacity: 0.65;
    }
    .index-content .blue-button {
      width: 100px;
      -webkit-transition: background-color 1s, color 1s;
      /* For Safari 3.1 to 6.0 */
      transition: background-color 0.5s, color 0.5s;
      min-height: 20px;
      background-color: #4CAF50;
      color: #ffffff;
      border-radius: 4px;
      text-align: center;
      font-weight: lighter;
      margin: 0px 20px 15px 20px;
      padding: 5px 0px;
      display: inline-block;
    }
    .index-content .blue-button:hover {
      background-color: #dadada;
      color: #002E5B;
    }
    /* Set width between block elements */
        .small-padding.top {
           padding-top:10px;
        }
    
        .small-padding.bottom {
            padding-bottom:10px;
        } 
        .small-padding.left {
            padding-left:5px;
        }
    
        .small-padding.right {
            padding-right:5px;
        }
    
        .row [class*="col-"] {
          padding-left: 5px;
          padding-right: 5px;
        }
    
    /* Set full width on columns */
    @media (max-width: 768px) {
        .img-responsive {
        width: 100%;
        }
    }
    
    /* GRID ELEMENTS MEDIA QUERIES */
    @media (min-width: 768px) {
      .card {
        position: relative;
      }
      .card-content {
        position: absolute;
        bottom: 0;
        width: 100%;
        background: rgba(0, 0, 0, 0.5);
      }
      .card-content h4,
      .card-content p {
        color: white;
        width: 100%;
        float: left;
        margin: 0 0 5px;
      }
      .card-content a {
        float: right;
      }
      .index-content .card h4,
      .index-content .card p {
        padding: 15px 20px;
        margin: 0;
      }
      .index-content .card p {
        padding: 0 20px 15px;
        margin: 0;
      }
    }
    .margin_bottom {
      margin-bottom: 10px;
    }
    .row [class*="col-"] {
      padding-right: 5px;
      padding-left: 5px;
    }
    .row {
      margin-left: -5px;
      margin-right: -5px;
    }
    .card-img-bottom {
      color: #fff;
      height: 20rem;
      background: url(images/img1.jpg) center no-repeat;
      background-size: cover;
    }
    .img-responsive { 
        height: 100%;
    }
    /* Button Position */
    .centered {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    .bottom-right {
        position: absolute;
        bottom: 8px;
        right: 16px;
    }
    
    .bottom-left {
        position: absolute;
        bottom: 8px;
        left: 16px;
    }
    
    .wrap {
      text-align: center;
      background: none;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <div class="container">    
       
        <!-- Col 1 - 1 - 2 -->
        <div class="row">
            <div class="col-sm-3 margin_bottom">
                <img src="http://placehold.it/300x410" alt="5" class="img-responsive"></img>
                <div class="wrap centered">
                  <h3>HEADLINE</h3>
                  <button class="btn btn-default "style="background-color:transparent;border:2px solid black;">See Offer</button>
                </div>
            </div>
            <div class="col-sm-6 margin_bottom">
                <img src="http://placehold.it/600x410" alt="5" class="img-responsive" />
                <div class="wrap bottom-left">
                  <h3>HEADLINE</h3>
                  <button class="btn btn-success">See Offer</button>
                </div>
            </div>
            <div class="col-sm-3">
                <div class="row">
                    <div class="col-xs-6 col-sm-12 margin_bottom">
                        <img src="http://placehold.it/300x200" alt="5" class="img-responsive" />      
                        <div class="wrap centered">
                          <h3>HEADLINE</h3>
                          <button class="btn btn-success">See Offer</button>
                        </div>
                    </div>
                    <div class="col-xs-6 col-sm-12 margin_bottom">
                        <img src="http://placehold.it/300x200" alt="5" class="img-responsive" />
                        <div class="wrap centered">
                          <h3>HEADLINE</h3>
                          <button class="btn btn-success">See Offer</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        
    </div>