我需要在右侧放置一个 div。在大屏幕上,它会正确定位自己。
但是当在小屏幕上时,选项和文本被定位到非常靠右的位置。我想在小型设备、中心选项、文本和按钮上将白色背景扩展到全宽。现在文本被剪切。
代码笔:
https://codepen.io/ogonzales/pen/GPEBbW
大屏幕:
小屏幕:
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/