Margin between my boxes CSS - html

I have those 3 boxes
and I want to have some margin inbetween them. As soon as I add margin, the 3rd one goes to the next row. Here's the code:
CSS:
#hotels {
background: url('../img/PICS/19427110_ml.jpg');
background-size: 100%;
height:10px;
color:whitesmoke;
}
.contenhotelsclass {
border-radius:10px;
padding: 70px;
height: 700px;
background: rgba(0, 0, 13, 0.6);
}
.contentsfirst {
padding-top: 100px;
padding-bottom: 100px;
}
If I add
.marginyes {
margin: 0 30px;
}
The next row thing happens.
HTML:
<section id="hotels">
<div class="row">
<div class="col-md-12 contentsfirst" id="contenthotels">
<div class="col-md-4 contenhotelsclass">
<img src="{{ URL::asset('img/PICS/18911510_ml.jpg') }}" class="img-circle img-responsive"> </img>
<span><h2>{{ Str::upper($wording['training']->container) }}</h2></span>
<span style="padding-top: 100px">{{ Str::limit($wording['training']->wording , 400, '...') }}</span>
<span ><p style="padding-top: 30px;"><button id="trainbutton" class="btn btn-success">Read more!</button></p></span>
</div>
<div class="col-md-4 contenhotelsclass marginyes">
<img src="{{ URL::asset('img/PICS/20360155_m.jpg') }}" class="img-circle img-responsive"> </img>
<span><h2>{{ Str::upper($wording['taste']->container) }}</h2></span>
<span style="padding-top: 100px">{{ Str::limit($wording['taste']->wording ,400,'...') }}</span>
<span><p style="padding-top: 30px;"><button id="eatbutton" class="btn btn-success">Read more!</button></p></span>
</div>
<div class="col-md-4 contenhotelsclass">
<img src="{{ URL::asset('img/PICS/31786072_ml.jpg') }}" class="img-circle img-responsive"> </img>
<span><h2>{{ Str::upper($wording['relax']->container) }}</h2></span>
<span style="padding-top: 100px">{{ Str::limit($wording['relax']->wording ,400,'...') }}</span>
<span><p style="padding-top: 30px;"><button id="relaxbutton" class="btn btn-success">Read more!</button></p></span>
</div>
</div>
</div>
</section>
I'm using bootstrap 3.
How could I solve this?

there is a solution.
change your DOM
old:
<div class="col-md-4 contenhotelsclass">
........
</div>
new:
<div class="col-md-4">
<div class="contenhotelsclass">
.....
</div>
</div>
add following css:
.contenhotelsclass {margin:0px 10px;}
jsFiddle http://jsfiddle.net/mp9napL3/1/

Firstly, I don't understand why you use margin: 0 30px;, I usually use just margin:30px;.
Secondly, the answer is that you have so much spacing between your boxes, your browser just puts the last box on the next line. Use a wider browser and your 3rd box won't go on the next line.

It is obvious, you are using col-md-4 means 25% of parent and when you set extra margin your div covers greater than 25%, the only way is to override col-md-4 class and reduce width from 25% to less.

Related

bootstrap margin under 576px

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

Bootstrap - Badge in Img mantain responsive

I need a badge within an img - independently from the window size - So far I have in my html following code (btw. I'm using Angular - but framework should be irrelevant):
.icon-container {
display: inline-block;
position: relative;
}
troop-level-badge {
position: absolute;
bottom: 2px;
left: 2px;
}
`
<div class="container row" *ngIf="img">
<div class="col-md-1">
<div class="icon-container">
<img class="rounded" [src]="img" width="40" height="auto">
<span class="badge badge-dark troop-level-badge">6</span>
</div>
</div>
</div>`
so far the result looks like this (as expected):
But when i resize the window the badge breaks out of the div. Does
someone know how i can contain the badge within the img even by resizing the window?
Your troop-level-badge rule isn't valid. There is a missing point. So replace troop-level-badge with .troop-level-badge and it should work like the following. To display the badge on the right side you need to set right:2px; instead of left:2px;:
.icon-container {
display:inline-block;
position:relative;
}
.troop-level-badge {
bottom:2px;
position:absolute;
right:2px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<div class="container row" *ngIf="img">
<div class="col-md-1">
<div class="icon-container">
<img class="rounded" src="https://placehold.it/100x100" >
<span class="badge badge-dark troop-level-badge">6</span>
</div>
<div class="icon-container">
<img class="rounded" src="https://placehold.it/75x75" >
<span class="badge badge-dark troop-level-badge">6</span>
</div>
<div class="icon-container">
<img class="rounded" src="https://placehold.it/50x50" >
<span class="badge badge-dark troop-level-badge">6</span>
</div>
</div>
</div>

Two column bootstrap layout without any padding or spaces

This is similar to the layout I'm trying to achieve:
The code I have now
<div class="row ">
<div class="col-lg-6 row-eq-height push-right">
<img src="1.jpg" class="img-responsive">
</div>
<div class="col-lg-6 row-eq-height">
<div class="eq-row-text ">
<p class="row-text">Text description for image </p>
</div>
</div>
</div>
<div class="row ">
<div class="col-lg-6 row-eq-height ">
<div class="eq-row-text ">
<p class="row-text"> Text description for the image </p>
</div>
</div>
<div class="col-lg-6 row-eq-height">
<img src="1.jpg" class="img-responsive">
</div>
</div>
I have tried using CSS class "no-padding" and also tried playing around with margins. when i apply 0 padding, the left side of the first image touches the edge of the browser( this is desired), however the other edge(right side of image) still has some empty space.
How do I get rid of that empty space get the results like the reference layout?
.col-md-6{
padding-right: 0px;
padding-left: 0px;
}
There could be an issue with the <p> padding/margin, could also be an issue with the <img> padding/margin. However it seems to be an issue with the sizing of the elements within the row.
I did however seemingly fix the issue in my PEN HERE
I added a height: *** to the row class, this may be needed for desired results as you are using row-eq-height bootstrap class.
HTML
<div class="row ">
<div class="col-lg-6 row-eq-height push-right">
<img src="1.jpg" class="img-responsive">
</div>
<div class="col-lg-6 row-eq-height">
<div class="eq-row-text ">
<p class="row-text">Text description for image </p>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 row-eq-height ">
<div class="eq-row-text ">
<p class="row-text"> Text description for the image </p>
</div>
</div>
<div class="col-lg-6 row-eq-height">
<img src="1.jpg" class="img-responsive">
</div>
</div>
CSS
p{
margin: 0;
padding: 0;
}
img{
margin: 0;
padding: 0;
}
.row {
margin: 0;
padding: 0;
height:60px;
background-color: #eee
}
If using the LESS/SASS source: change #grid-gutter-width in the variables file to 0
If you want to get rid of the white space you will need to make your image bigger to span the cols. You can manually adjust the width of an image using css:
img {
width: 100%;
}

Padding an image in Bootstrap with background colour

Couldn't find an answer to this so..
It's probably a very simple solution but I've been tunnel visioning for the past 20 minutes and it's frustrating me.
The padding of an image, which I'm trying to give a circle background element, is really annoying.
Margin doesn't work either.
My image is 120 px large, and the padding of 2em just makes it smaller, but I want it to stay the same size, but have a bigger background size.
Here's the code:
<div class="row">
</div class="container-fluid">
<div class="col-md-4 img-icon-pad">
<img src="img/icons/html.png" class="img-responsive img-icons" />
</div>
<div class="col-md-4">
<img src="img/icons/html.png" class="img-responsive img-icons" />
</div>
<div class="col-md-4">
<img src="img/icons/html.png" class="img-responsive img-icons" />
</div>
</div>
/* Boxes */
.img-icons {
height: 120px;
width: auto;
background-color: #f8f8ec;
border: 2px solid #e97117;
padding: 2em;
border-radius: 50%;
}
.img-icon-pad {
}
And a screenshot of what I mean:
No padding
https://i.gyazo.com/745896ad418274f70e8189f6b84c7b6d.png
Padding:
https://i.gyazo.com/b2a264d8a361a426cc43992d90352e79.png
I think it is ok
<div class="row">
<div class="container-fluid">
<div class="col-md-4 ">
<div class="thumbnail">
<img src="img/icons/html.png" class="img-responsive img-icons" />
</div>
</div>
<div class="col-md-4">
<img src="img/icons/html.png" class="img-responsive img-icons" />
</div>
<div class="col-md-4">
<img src="img/icons/html.png" class="img-responsive img-icons" />
</div>
</div>
<style>
.thumbnail {
height: 150px;
width: 150px;
border: 2px solid #e97117;
background-color: #f8f8ec;
padding: 2em;
}
</style>
Did you increase the height of .img-icons class from 120 to 150px or bigger if you want.
If that doesn't work then you have probably restricted size of the div containing the img.
I was going to say that in .img-icons class you have width set to auto. This may be causing resizing. If you set it to a fixed width it may not resize.
i think this is what are you trying to do :
<div class="row">
<div class="col-md-4">
<div class="img-responsive img-icons" >
<div class="img">
</div>
</div>
</div>
</div>
css:
.img-icons {
height: 120px;
width:120px;
background-color: #f8f8ec;
border: 2px solid #e97117;
border-radius: 50%;
padding: 2em;
}
.img{
text-align:center;
height:120px;
width:120px;
background-color: #f8f8ec;
border: 2px solid #e97117;
}
you can see the result here https://jsfiddle.net/nt0zqc1t/3/

Image fall behind container

On my page, I use two col-sm-6 blocks inside a containter, to display two blocks beside each other.
In the right block I added a image, with position absolute, so that I can place it at the righ of the screen.
But I want to let the image fall behind the max page width, so that the image is dispayed for only 3/4, but now it is on top of it and make the page larger.
How can I let the image fall behind the max page width, so that horizontal scrolling is not possible?
Screenshot:
HTML:
<div class="row multi-column-row" style="min-height: 643px;">
<div class="spb-column-container col-sm-6 full-image-right-block-text " style="margin-top: 0px; margin-bottom: 0px; padding: 0px; min-height: 643px;">
<div class="spb-asset-content" style="padding: 0%; margin-top: 65px; margin-bottom: 65px;">
<section class="container "><div class="row">
<div class="spb_content_element col-sm-12 spb_text_column mt0 mb0">
<div class="spb-asset-content" style="margin-top: 0px;margin-bottom: 0px;border-top: 0px default ;border-left: 0px default ;border-right: 0px default ;border-bottom: 0px default ;padding-top: 0px;padding-left: 0px;padding-right: 0px;padding-bottom: 0px;">
<h4> Title </h4>
<h5>Title</h5>
<p>Text</p>
</div>
</div> </div></section>
</div>
</div>
<div class="spb-column-container col-sm-6 full-image-right-block " style="margin-top: 0px; margin-bottom: 0px; padding: 0px; min-height: 643px;">
<div class="spb-asset-content" style="padding:0%;">
<section class="container "><div class="row">
<div class="spb_content_element spb_image noframe col-sm-12 thumbnail-gallery-standard square-corners">
<div class="spb-asset-content"><figure class="clearfix" style="width:1050px;margin:0 auto;">
<div class="img-wrap"><img width="2148" height="1255" src=""></div><div class="figcaption-wrap"></div></figure>
</div>
</div> </div></section>
</div>
</div> </div>