html - CSS:在小屏幕上全宽的 div 不起作用

标签 html css twitter-bootstrap bootstrap-4

我需要在右侧放置一个 div。在大屏幕上,它会正确定位自己。

但是当在小屏幕上时,选项和文本被定位到非常靠右的位置。我想在小型设备、中心选项、文本和按钮上将白色背景扩展到全宽。现在文本被剪切。

代码笔:

https://codepen.io/ogonzales/pen/GPEBbW

大屏幕:

enter image description here

小屏幕:

enter image description here

HTML:

<div class="row">

    <div class="col-md-6">
        <h1>Mis Stickers</h1>
        <p>858 reviews</p>

        <img src="{{ product.image.url }}">

        <p>Custom kiss cut stickers easily peel away from the backing. Print on the surrounding border
                    as
                    well as the stickers. Made from durable vinyl that resists scratching, heat, water and
                    sunlight.</p>
      </div>

      <div class="col-md-6 col-xs-12 col-sm-12">

      <div class="m-5 bg-white col-sx-12">

      <div class="padded">

      <form method="post">

         <div id="size">


       <button type="submit" class="btn btn-naranja text-white btn-block">Continuar
       </button>
                                                               <a  href="#" class="btn btn-naranja text-white btn-block">Continuar#}
       </a>
       </br>
       <p>Siguiente: subir imagen</p>

      </form>

      </div>
     </div>

    </div>
   </div>

最佳答案

当您需要为特定的屏幕尺寸使用一些 CSS 时,您可以使用@media。现在您应该在 CSS 的末尾添加以下代码:

@media only screen and (max-width: 600px) {
.padded {
  padding: 0px;
}
  .bg-Smal{
    background-color: #ffffff;
  }
}

此外,将 bg-Smal 类添加到第一个 div 中:

    <div class="row">

    <div class="col-md-6">
        <h1>Mis Stickers</h1>
        <p>858 reviews</p>

        <img src="{{ product.image.url }}">

        <p>Custom kiss cut stickers easily peel away from the backing. Print on the surrounding border
                    as
                    well as the stickers. Made from durable vinyl that resists scratching, heat, water and
                    sunlight.</p>
      </div>

      <div class="bg-Smal col-md-6 col-xs-12 col-sm-12">

      <div class="m-5 bg-white col-sx-12">

      <div class="padded">

      <form method="post">

         <div id="size">


       <button type="submit" class="btn btn-naranja text-white btn-block">Continuar
       </button>
                                                               <a  href="#" class="btn btn-naranja text-white btn-block">Continuar#}
       </a>
       </br>
       <p>Siguiente: subir imagen</p>

      </form>

      </div>
     </div>

    </div>
   </div>

欲了解更多信息,您可以访问此链接:https://www.w3schools.com/csSref/css3_pr_mediaquery.asp

关于html - CSS:在小屏幕上全宽的 div 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53928933/

相关文章:

html - 如何通过 CSS 在同一个 <img> 标签中设置一个图像在另一个图像之上?

html - 将 div 高度扩展到文档高度

html - 使用 <a> 作为按钮的纯 CSS 选项卡

javascript - rails 中的 Ladda 加载按钮

html - 输入占位符在 Firefox 中未垂直对齐

javascript - 无法使用 sencha 在屏幕底部的面板中显示 2*2 按钮以及屏幕顶部的轮播

css - 固定高度表,单元格内容带有 overflow-x

css - 为什么我的 div 没有脱离父 div?

css - 我需要自定义 ng-grid

javascript - 上次保存值的 Jquery UI slider 句柄