I implement a bootstrap site. I have an issue in the case the width of the screen is under 576 px (xs for bootstrap)
Don't pay attention to details, I am only interested in the margin of the content in red
<div class="container">
<div class="col-xs-12" *ngIf="innersize < 576">
<div class="row">
<div style="background-color: red"*ngFor="let pr of annonces; let index = index;" class="col-xs-12">
<div id="prePreviousMapIdXS" [style.height.px]="0" *ngIf="index === (insertIndex-1)"></div>
<div id="previousMapIdXS" [style.height.px]="0" *ngIf="index === insertIndex"></div>
<div id="card{{index}}IdXS">
<app-product-light (mouseenter) ="mouseEnterProduitImmobilier(index)" (mouseleave) ="mouseLeaveProduitImmobilier(index)" [produit]="pr"></app-product-light>
</div>
<div id="listXSMap" [style.margin-bottom.px]="25" [style.width.px]="cardWidth" [style.height.px]="cardHeight" *ngIf="index === insertIndex" >
<agm-map #gm [latitude]="mainLatitude" [longitude]="mainLongitude" [style.height.px]="computeMapXSHeight()" [fitBounds]="true">
<agm-marker *ngFor="let marker of markers; let index = index" [latitude]="marker.latitude" [longitude]="marker.longitude" [iconUrl]="markers[index].markerIcon" [animation]="markers[index].markerAnimation" (markerClick)="clickedMarker(infoWindow, gm)" [agmFitBounds]="true">
<agm-info-window [disableAutoPan]="false" #infoWindow [maxWidth]="350">
<span class="">
<div style="float: left;">
<img width="70" height="40" src="../../assets/images/maison1.png" alt="Card image cap">
</div>
<div style="float: right; padding-left: 10px">
<div class="poppinsbold10diese372300 whitespacenowrap">{{annonces[index].nbrPiece}}
Pièces / {{annonces[index].nbrChambre}} Chambres / {{annonces[index].surfaceHabitable}}m<sup>2</sup>
</div>
<div class="poppinsregular8diese171717DE whitespacenowrap opacity05 ">
{{annonces[index].adresse}} / {{annonces[index].ville}} / {{annonces[index].codePostal}}
</div>
<div class="poppinsextrabold10diese372300 whitespacenowrap" style=" margin-top: 5px">
{{annonces[index].prix | currency:'EUR':'symbol':'1.0-0':'fr'}}
</div>
</div>
</span>
</agm-info-window>
</agm-marker>
</agm-map>
</div>
</div>
</div>
</div>
</div>
Here is the fiddle : https://jsfiddle.net/boilerplate/bootstrap
The issue is that when I resize the width under 576px, there is no more margin. Above that size there is a margin
That's the default behavior of .container on mobile devices: width: 100%. If you want to limit it to say 94% of the available device width below 576px, use this CSS:
#media (max-width: 575px) {
.container {
width: 94%;
}
}
See it here: https://jsfiddle.net/websiter/p1n0j4vu/
Change 94% to whatever makes sense for your project.
For example, if you want to maintain fixed margins of 30px below that responsiveness breakpoint, you could use calc(100% - 60px).
The issue is that you're using the container class for your container. You can instead use the container-fluid class and style it to have padding. Here's a JSFiddle. The difference between the container class and container-fluid class is that the container class will resize and adjust its margin depending on the size of the viewport. Here is the adjusted code:
HTML:
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container-fluid">
<div class="row">
<div class="col">
1 of 2
</div>
<div class="col">
2 of 2
</div>
</div>
<div class="row">
<div class="col">
1 of 3
</div>
<div class="col">
2 of 3
</div>
<div class="col">
3 of 3
</div>
</div>
</div>
CSS:
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
.container-fluid {
padding: 0 30px;
}
I finally found a solution without understandind it
In place of
col-xs-12
I put everywhere
col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12
and it works
Related
No matter what I try, my footer is not filling the full screen width. What can I do?
body width 100% did not work
I tried this, too: Bootstrap Footer, Full Width Of Page
I am working in Angular 11 & Bootstrap 5.
html
<div class="container">
<div class="row align-items-center">
<div class="contentLeftCorner col-sm-4">
<div class="footerComponents me-5" >sth</div>
</div>
<div class="contentCenter col-sm-4"></div>
<div class="contentRightCorner col-sm-4">
<div class="row">
<div class="col-sm-6">
<div class="footerComponents me-5">1</div>
<div class="footerComponents me-5">2</div>
<div class="footerComponents me-5">3</div>
<div class="footerComponents me-5">4</div>
</div>
<div class="col-sm-6">
<div class="footerComponents 5 me-5">a</div>
<div class="footerComponents 5 me-5">b</div>
<div class="footerComponents 5 me-5">c</div>
<div class="footerComponents 5 me-5">d</div>
</div>
</div>
</div>
</div>
</div>
CSS
.footerComponents:hover {
cursor:pointer ;
color: dimgrey;
}
.footerComponents{
border-color: transparent;
}
//no borders on clicked element
*:focus {
outline: 0;
}
.contentRightCorner {
font-size: 0.7rem;
}
Set .conatainer's padding to 0, and .row's width to 100% and remove gutter position on .row. Also remove me-5 class from footerComponents.
.container {
padding: 0 !important;
background-color: aquamarine;
}
.row {
--bs-gutter-x: 0 !important;
width: 100%;
}
.footerComponents {
border: 1px solid red;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta2/js/bootstrap.min.js"></script>
<div class="container">
<div class="row align-items-center">
<div class="contentLeftCorner col-sm-4">
<div class="footerComponents">sth</div>
</div>
<div class="contentCenter col-sm-4"></div>
<div class="contentRightCorner col-sm-4">
<div class="row">
<div class="col-sm-6">
<div class="footerComponents">1</div>
<div class="footerComponents">2</div>
<div class="footerComponents">3</div>
<div class="footerComponents">4</div>
</div>
<div class="col-sm-6">
<div class="footerComponents">a</div>
<div class="footerComponents">b</div>
<div class="footerComponents">c</div>
<div class="footerComponents">d</div>
</div>
</div>
</div>
</div>
</div>
Note: I have added background-color and border properties to show the exact positions.
Hope, this will help you.
I think this is due to your footerComponents being inside of <div> with the class container. As Bootstrap 5 has set a max-width for the container class on certain size screen. The container class is only 100% on extra small screen. You can refer to the documentation here.
.container max-width
Extra small <576px : 100%
Small ≥576px : 540px
Medium ≥768px : 720px
Large ≥992px : 960px
X-Large ≥1200px : 1140px
XX-Large ≥1400px : 1320px
You can try and bring the footerComponents <div> outside of the container <div> for this.
The other option is to go with container-fluid class which is 100% at all breakpoints.
Put it outside of container DIV.
I created some Cards using bootstrap, html and css. Unfortunately, when I change the size of the screen the cards do not adjust accordingly.
This is how they look right now before changing the size.
When I go to inspect and switch it to ipad, it looks like this:
I tried using a media query in my css folder to solve this, but no luck. Can someone tell me what I am doing wrong? EDIT: Ideally, I would like to have one card on top of another when changing the screen size. I would also like to have the spacing in between the cards as well.
<div class="col-md-4">
<div class="ScoreCard">
<div>
<h3 style="background-color:#item.TitleColor"> #item.ReportName - #item.TitleColor </h3>
</div>
<div class="col-lg-4">
<div style="font-weight:bold; margin-top:35px;">
<h1>GrossAmountDue</h1>
</div>
</div>
<div class="col-lg-2" style="margin-top:35px;">
if (Flag == 1)
{
<i class="fas fa-circle" style="font-size:30px; color:red; margin-left:15px;"></i>
}
</div>
<div class="col-lg-6">
<div>
<p style="font-size:20px; margin-left: 25px;">Audited </p>
<p style="font-size:20px; margin-left: 25px;">Packages: Will go here</p>
<p style="font-size:20px; margin-left: 25px;">Transactions will go here</p>
<p style="font-size:20px;"Icon will go here</p>
</div>
</div>
<div class="row">
<div class="col-lg-12" style="margin-top: 5px;">
<p style="margin-left:17px;">Text Here</p>
</div>
</div>
</div>
</div>
//CSS
<style>
.ScoreCard {
background-color: orange;
width: 500px;
min-height: 200px;
border: 15px black;
}
##media screen and (max-width: 100px){
.col{
width: 50%;
}
}
</style>
You have to wrap your cols in a row like this:
<div class="row">
<div class="col-md-12 col-lg-4">
<div class="card">...</div>
</div>
<div class="col-md-12 col-lg-4">
<div class="card">...</div>
</div>
<div class="col-md-12 col-lg-4">
<div class="card">...</div>
</div>
</div>
In this way, when you have a screen equal or less of md, contents of cols goes one on top of another, but when screen is lg or higher, you have 3 cols in a row.
INFO
In your media query you are changing the col class, when instead you are using col-md-4
I have a page with a banner and 3 columns, and I am trying to make it so that when the screen width gets too small, that the first 2 columns change from 1/3rd width to 50% width and the last column width change to 100% so that it's below the first two.
When I do this, the height of the columns does change (they change to 50%, considering the columns will now fit underneath each other inside a 100% row), but the width does not. How could I fix this? Thanks in advance!
Codepen
HTML
<section class="section">
<div class="container-fluid">
<div class="aboutBanner"> </div>
<div class="row">
<div class="col">
</div>
<div class="col">
</div>
<div class="col">
</div>
</div>
</div>
</section>
related CSS
.aboutBanner {
height: 30%;
border: 1px solid blue;
}
.row {
height: 70%;
}
.row .col {
height: 100%;
border: 1px solid red;
}
#media screen and (max-width: 768px){
.row .col:nth-of-type(1),
.row .col:nth-of-type(2) {
height: 50%;
width: 50%;
}
.row .col:nth-of-type(3) {
height: 50%;
width: 100%;
border-style: dashed;
}
}
Use the Bootstrap responsive grid columns...
https://codepen.io/anon/pen/eMzRyb
<section class="section">
<div class="container-fluid">
<div class="aboutBanner">
</div>
<div class="row">
<div class="col-sm-4 col-6">
</div>
<div class="col-sm-4 col-6">
</div>
<div class="col-sm-4 col-12">
</div>
</div>
</div>
</section>
To visualize this in your codepen I changed the CSS...
.row {
height: 70%;
}
.row > div {
border: 1px solid red;
}
Also see:
What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap?
Use bootstrap col-[size] class
See documentation
The bootstrap grid is based in 12 columns sizes, that are divided in 5 screen sizes:
Extra small
col-[1 to 12]
Small
col-sm-[1 to 12]
Medium
col-md-[1 to 12]
Large
col-lg-[1 to 12]
Extra large
col-xl-[1 to 12]
Try this:
<section class="section">
<div class="container-fluid">
<div class="aboutBanner"> </div>
<div class="row">
<div class="col-md-4 col-sm-6">
content of first
</div>
<div class="col-md-4 col-sm-6">
content of second
</div>
<div class="col-md-4 col-sm-12">
content of third
</div>
</div>
</div>
</section>
Keep in mind that 12 is 100%, 6 is 50%, 4 is 33%, 3 is 25% and so on...
I've read 5-6 question / answers but can't find what I'm looking for _
Bootstrap 4 columns aren't behaving the way I expect them to. Below about 600px device width the edge overflows instead of continuing to reduce in size
at 618px the columns are still reducing
at 538px the columns are overflowing
HTML:
<div class="container">
<div class="row">
<div class="col-lg-9 col-md-12">
<div class="outerDivBorder" id="photoBox">
<div style="height: 10em;"></div>
</div><!-- /#photoBox -->
</div>
<div class="col-lg-3 col-md-12">
<div class="outerDivBorder" id="dataBox">
<div style="height: 10em;"></div>
</div><!-- /#dataBox -->
</div>
</div>
</div><!-- /.container -->
CSS:
.outerDivBorder {
width: 100%;
border: 1px solid #454343;
padding: 0 1rem;
margin: 1rem;
margin-top: 1.5rem;
margin-bottom: 2rem;
}
Thanks in advance for any guidance offered on this : )
You put margin: 1rem; on .outerDivBorder, and that margin pushes content out on small screens. Use padding on cols instead - it can be done by using utility class for padding, py-3 in this case:
.outerDivBorder {
width: 100%;
border: 1px solid #454343;
padding: 0 1rem;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-lg-9 col-md-12 py-3">
<div class="outerDivBorder" id="photoBox">
<div style="height: 10em;"></div>
</div>
</div>
<div class="col-lg-3 col-md-12 py-3">
<div class="outerDivBorder" id="dataBox">
<div style="height: 10em;"></div>
</div>
</div>
</div>
</div>
Had a similar problem. On mine it was happening because of
* {
box-sizing: inherit;
}
Bootstrap already reset that to border-box and the col's and row's behave according to that.
I would like to know how easilly achieve this layout with Bootstrap 3.
You can achieve that layout using bootstrap 3 pretty easy, you just have to arrange your columns in a proper order. The orange~red block I believe its a sidebar, and the other two blocks have the same width (seems bound to the same container), and I think there you have your content.
So, put the sidebar block, in a container with the desired width from the bootstrap grid, like col-md-4, and the content block in a container say col-md-8; add to both these containers col-xs-12 class(will add 100% width on 768px and bellow), we'll need it because we're gonna use pull-left/right(float rule) class to swap them around.
Check out the demo and bellow the markup/css used
The markup:
<div class="container">
<div class='row cf'>
<div class='col-sm-4 col-xs-12 pull-right'>
<div class='orange'>One good lookin sidebar</div>
</div>
<div class='col-sm-8 col-xs-12 pull-left'>
<div class='content-entry orchid'>
Some content here
</div>
<div class='content-entry cyan'>
And some other content here
</div>
</div>
</div>
</div>
And the css:
.orange{
background: orange;
}
.orchid{
background: orchid;
}
.cyan{
background: cyan;
}
**Note: if you want that sidebar to expand it's height to the height of the other 2 blocks combined, that's a different story, but this should get you started.
UPDATE 2
OK since you have a layout a bit tricky on mobile, I guess your safest bet would be to make the sidebar absolute positioned, and on mobile(bellow and 767px), switch it to static position, to make em fall into a natural flow. There are some more other methods out there like flexbox, or maybe some fancy table tricks, but this one should get you going.
Check out the demo, and the changed markup/css bellow:
<div class="container">
<div class='row content-wrapper'>
<div class='col-sm-8 col-xs-12'>
<div class='content-entry orchid'>
Some content here
</div>
</div>
<div class='col-sm-4 col-xs-12 sidebar-wrapper'>
<div class='orange'>One good lookin sidebar</div>
</div>
<div class='col-sm-8 col-xs-12'>
<div class='content-entry cyan'>
And some other content here
</div>
</div>
</div>
</div>
.orange{
background: orange;
}
.orchid{
background: orchid;
}
.cyan{
background: cyan;
}
/*added rules*/
.content-wrapper{
position: relative;
}
.sidebar-wrapper{
position: absolute;
top: 0; right: 0;
}
#media all and (max-width: 767px){
.sidebar-wrapper{
position: static;
}
}
Have a look here, I think the .col-md-8 and .col-md-4 classes will be interesting for you.
Since stack Overflow will not do any project i posted you simple and easy step
Bootstrap use media-queries
example
#media screen and (max-width: 500px) {
div {
width: 80%
}
}
this above query works if screen is bellow 500px div width will be 80%
try this example
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: lightgreen;
}
#media screen and (max-width: 600px) {
body {
background-color: lightblue;
}
}
</style>
</head>
<body>
<p>Resize the browserwindow. When the width of this document is less than 300 pixels, the background-color is "lightblue", otherwise it is "lightgreen".</p>
</body>
</html>
Above example will show when screen size is bellow 600px page color will change from lightgreen to lightblue
<body class="container">
<div class="row">
<div class="col-sm-6 col-xs-12">orange</div>
<div class="col-sm-6 col-xs-12">
<div class="row">violet row</div>
<div class="row">light blue</div>
</div>
</div>
</body>
I used xs-12 for the mobile. Please post your example code next time.
Thank you for all your answers.
Here's what i've made with the help of all answers :
<div class="container">
<div class="row">
<div class="col-sm-8 bg-info">
<h4>Content 1</h4>
</div>
<div class="col-sm-4 bg-warning pull-right">
<h4>Sidebar</h4>
</div>
<div class="col-sm-8 bg-success pull-left">
<h4>Content 2</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-8" style="background-color:purple; color:#fff">Contents box 1</div>
<div class="col-xs-12 col-md-4" style="background-color:red; color:#fff">Sidebar</div>
<div class="col-xs-12 col-md-8" style="background-color:blue; color:#fff">Contents box 2</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-xs-12 col-md-8" style="background-color:purple; color:#fff">Contents box 1</div>
<div class="col-xs-12 col-md-4" style="background-color:red; color:#fff">Sidebar</div>
<div class="col-xs-12 col-md-8" style="background-color:blue; color:#fff">Contents box 2</div>
</div>