Centering container in CSS, after deleting a 4th box - html

I have deleted a 4th box as i only need 3 and want the centre the 3 boxes. Here is an image. This is my CSS Code. Below is the HTML code, Keeps saying there is too much code so I am filling up this part with more text so hopefully I can get some help at some point, hopefully this is enough text to code now ?
#featured-wrapper {
overflow: hidden;
padding: 5em 0em;
background: #FFF;
}
#featured h2 {
text-align: center;
}
#featured .icon {
position: relative;
display: block;
background: #2A70E8;
margin: 0px auto 20px auto;
line-height: 2.5em;
font-size: 4em;
text-align: center;
color: #FFF;
}
.column1,
.column2,
.column3,
.column4 {
width: 282px;
}
.column1,
.column2 {
float: left;
margin-right: 24px;
}
.column3 {
float: left;
}
.column4 {
float: right;
}
<div id="featured-wrapper">
<div id="featured" class="container">
<div class="major">
<h2>Maecenas lectus sapien</h2>
<span class="byline">Cras vitae metus aliquam risus pellentesque pharetra</span>
</div>
<div class="column1">
<span class="icon icon-bar-chart"></span>
<div class="title">
<h2>Maecenas lectus sapien</h2>
<span class="byline">Integer sit amet aliquet pretium</span>
</div>
</div>
<div class="column2">
<span class="icon icon-qrcode"></span>
<div class="title">
<h2>Praesent scelerisque</h2>
<span class="byline">Integer sit amet aliquet pretium</span>
</div>
</div>
<div class="column3">
<span class="icon icon-building"></span>
<div class="title">
<h2>Fusce ultrices fringilla</h2>
<span class="byline">Integer sit amet aliquet pretium</span>
</div>
</div>
</div>
</div>

we need to see your HTML to give You a correct Answer
but try this
replace this code
#featured-wrapper {
overflow: hidden;
padding: 5em 0em;
background: #FFF;
}
with this
#featured-wrapper {
width:900px;
margin:0 auto;
overflow: hidden;
padding: 5em 0em;
background: #FFF;
}
and you can change this number 900
with the best width for the HTML

Try wrapping the 3 columns in a div with a columnwrap class like:
.columnwrap {
width: 846px; //width of your 3 columns combined, add px for padding if needed
margin: auto;
}
then:
<div class="columnwrap">
<div class="column1"></div>
<div class="column1"></div>
<div class="column1"></div>
</div>
You are going to need to clearfix the three floats before the closing div tag on the columnwrap. This should do the trick.

you can avoid float and use .column {display:inline-block} + .parent .column {text-align:center}.
Snippet to test below
#featured-wrapper {
overflow: hidden;
padding: 5em 0em;
background: #FFF;
text-align:center;/* new */
}
#featured h2 {/* cleaned up */
}
#featured .icon {
position: relative;
display: block;
background: #2A70E8;
margin: 0px auto 20px auto;
line-height: 2.5em;
font-size: 4em;
text-align: center;
color: #FFF;
}
.column1,
.column2,
.column3,
.column4 {
width: 282px;
display:inline-block;/* new instead float*/
margin:0 10px;/* update*/
}
.column1,
.column2 {/* cleaned up */
}
.column3 {/* cleaned up */
}
.column4 {/* cleaned up */
}
<div id="featured-wrapper">
<div id="featured" class="container">
<div class="major">
<h2>Maecenas lectus sapien</h2>
<span class="byline">Cras vitae metus aliquam risus pellentesque pharetra</span>
</div>
<div class="column1">
<span class="icon icon-bar-chart"></span>
<div class="title">
<h2>Maecenas lectus sapien</h2>
<span class="byline">Integer sit amet aliquet pretium</span>
</div>
</div>
<div class="column2">
<span class="icon icon-qrcode"></span>
<div class="title">
<h2>Praesent scelerisque</h2>
<span class="byline">Integer sit amet aliquet pretium</span>
</div>
</div>
<div class="column3">
<span class="icon icon-building"></span>
<div class="title">
<h2>Fusce ultrices fringilla</h2>
<span class="byline">Integer sit amet aliquet pretium</span>
</div>
</div>
</div>
</div>

Related

Using flex with a ribbon card component with offset cards. How to align items which are variable in length

Apologies in advance if this is a badly worded question. I am trying to build a component which looks like this from the design:
We have a tagline and title then the option to have 1 to 4 cards in the ribbon. These are ordered using flex-direction: row-reverse (so they stack from the right hand side first).
We pass a data attribute via the backend, so we can target a ribbon with 1 - 4 cards.
So far I have built this using offsets of padding, margins and height, this works well when we have copy as we expect, but if the title is very short (or long) everything gets messed up. I am not even sure (given the way the component has been built) if this is even possible. Mobile is fine, and 1 or 2 cards is OK, but 3 or 4 gets tricky. We want to align the first two at the top (from the right hand side) then the third is taller and should align at the bottom with the 4th card (so 3 and 4 have an offset). Maybe it is better to think of the title and tagline as being offset?
I have made this jsfiddle using the 4 card layout.
Here is the sample HTML:
<section class="ribbon-icon grid grid-container content-wrapper" data-columns="4">
<div class="row">
<div class="ribbon-icon__title col col--md-6">
<p class="ribbon-icon__tagline">Solutions</p>
<p class="h1">Improve the benefits that health care can provide Improve the benefits that health care can provide..</p>
<p class="ribbon-icon__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cursus porta rhoncus pharetra amet, consequat ullamcorper vitae sed. Dolor sem tellus nec risus magna.</p>
</div>
<div class="ribbon-icon__items row col">
<a class="ribbon-icon__items--item col col--md-3" href="/en-gb">
<div>
<img src="/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102">
</div>
<div>
<h3 class="ribbon-icon__item-title">Clinical studies</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3" href="/en-gb">
<div>
<img src="/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102">
</div>
<div>
<h3 class="ribbon-icon__item-title">Clinical studies</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3" href="/en-gb">
<div>
<img src="/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D">
</div>
<div>
<h3 class="ribbon-icon__item-title">Patient information material</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3" href="/en-gb">
<div>
<img src="/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF">
</div>
<div>
<h3 class="ribbon-icon__item-title">Product information</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</a>
</div>
</div>
</section>
We are using scss but I have made a dump of the core css this relates to (it's in the fiddle of course) but here is the block:
.ribbon-icon {
margin-bottom: -4.5rem
}
#media (min-width:992px) {
.ribbon-icon {
margin-bottom: -2.5rem
}
}
.ribbon-icon__title {
margin: 0!important;
padding-left: 0;
padding-right: 0;
padding-bottom: 0
}
#media (min-width:768px) {
.ribbon-icon__title {
margin: 0 0 6rem!important
}
}
#media (min-width:768px) {
.ribbon-icon__title .h1 {
font-size: 2.5rem!important
}
}
.ribbon-icon__description {
margin-bottom: 0
}
.ribbon-icon__item-title {
font-weight: 600;
font-size: 1.4rem;
line-height: 1.5rem
}
#media (min-width:768px) {
.ribbon-icon__item-title {
font-size: 1.875rem;
line-height: 2.25rem
}
}
.ribbon-icon__items {
flex-direction: row-reverse!important;
padding-left: 0;
padding-right: 0;
padding-top: 0
}
#media (min-width:992px) {
.ribbon-icon__items {
position: relative;
top: -7rem
}
}
.ribbon-icon__items--item {
position: relative;
color: initial;
margin: 1.25rem 0 2.25rem;
text-decoration: none
}
.ribbon-icon__items--item:before {
content: "";
border-width: 0;
border-left: 1px solid;
border-image: linear-gradient(#b5007c, #007da3) 0 100%;
height: 100%;
position: absolute;
left: 0;
height: calc(100% - 1.2rem)
}
.ribbon-icon__items--item:hover {
color: initial
}
.ribbon-icon__items--item p {
margin: 0
}
.ribbon-icon__items--item img,
.ribbon-icon__items--item svg {
max-width: 3.25rem
}
#media (min-width:768px) {
.ribbon-icon__items--item img,
.ribbon-icon__items--item svg {
max-width: 5rem
}
}
#media (min-width:992px) {
.ribbon-icon__items--item {
position: relative;
margin: 0;
padding-bottom: 0
}
}
.ribbon-icon[data-columns="1"] .ribbon-icon__title {
flex: 0 0 75%;
max-width: 75%
}
#media (min-width:992px) {
.ribbon-icon[data-columns="3"] .ribbon-icon__items--item:nth-child(2),
.ribbon-icon[data-columns="4"] .ribbon-icon__items--item:nth-child(2) {
min-height: 30rem
}
}
#media (min-width:992px) {
.ribbon-icon[data-columns="3"] .ribbon-icon__items--item:nth-child(3),
.ribbon-icon[data-columns="3"] .ribbon-icon__items--item:nth-child(4),
.ribbon-icon[data-columns="4"] .ribbon-icon__items--item:nth-child(3),
.ribbon-icon[data-columns="4"] .ribbon-icon__items--item:nth-child(4) {
top: 7rem;
}
}
You can use float:left for the title and float:right for items:
.row {
border-top: 1px dotted gray;
margin-top: 4rem;
height: 100vh;
}
.row * {
box-sizing: border-box;
}
.ribbon-icon__title {
width: 40%;
float: left;
margin-left: 1rem;
}
.ribbon-icon__tagline {
font-size: 0.5rem;
font-style: italic;
font-weight: bold;
}
.row .h1 {
font-size: 0.8rem;
font-weight: bold;
}
.row p {
margin: 0.3rem;
}
.row .ribbon-icon__description {
font-size: 0.4rem;
}
.ribbon-icon__items--item {
float: right;
width: 24%;
margin-left: -1px;
margin-top: 1rem;
border-left: 1px solid pink;
border-right: 1px solid pink;
}
.ribbon-icon__items--item:first-of-type {
border-right: none;
}
.ribbon-icon__items--item:last-of-type {
border-right: none;
}
.ribbon-icon__items--item div {
display: inline-block;
width: 100%;
height: 110px;
margin: 0.5rem;
padding: 0.5rem;
}
.ribbon-icon__items--item img {
width: 50%;
height: 50%;
margin: 0 auto;
}
.ribbon-icon__items--item p {
font-size: 0.5rem;
margin: 0.2rem;
color: gray;
}
.ribbon-icon__item-title {
font-size: 0.6rem;
text-decoration: none;
color: black;
}
<section class="ribbon-icon grid grid-container content-wrapper" data-columns="4" data-tracking="ribbon-icon">
<span>To see all the use cases scroll down till bottom.</span>
<div class="row">
<div class="ribbon-icon__title col col--md-6">
<p class="ribbon-icon__tagline">Solutions</p>
<p class="h1">Improve the benefits that health care can provide.</p>
<p class="ribbon-icon__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cursus porta rhoncus pharetra amet, consequat ullamcorper vitae sed. Dolor sem tellus nec risus magna.</p>
</div>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Product information4</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D" />
<h3 class="ribbon-icon__item-title">Patient information material3</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102" />
<h3 class="ribbon-icon__item-title">Clinical in-depth studies2</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Webinars and e-learning</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
</div>
<div class="row">
<div class="ribbon-icon__title col col--md-6" style="width: 60%;">
<p class="ribbon-icon__tagline">Solutions</p>
<p class="h1">Improve the benefits that health care can provide.</p>
<p class="ribbon-icon__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cursus porta rhoncus pharetra amet, consequat ullamcorper vitae sed. Dolor sem tellus nec risus magna.</p>
</div>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Product information4</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D" />
<h3 class="ribbon-icon__item-title">Patient information material3</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102" />
<h3 class="ribbon-icon__item-title">Clinical in-depth studies2</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Webinars and e-learning</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
</div>
<div class="row">
<div class="ribbon-icon__title col col--md-6" style="width: 20%;">
<p class="ribbon-icon__tagline">Solutions</p>
<p class="h1">Improve the benefits that health care can provide.</p>
<p class="ribbon-icon__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cursus porta rhoncus pharetra amet, consequat ullamcorper vitae sed. Dolor sem tellus nec risus magna.</p>
</div>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Product information4</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D" />
<h3 class="ribbon-icon__item-title">Patient information material3</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102" />
<h3 class="ribbon-icon__item-title">Clinical in-depth studies 2</h3>
<p>Clinical trials, safety studies, and some more studies</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Webinars and e-learning</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
</div>
<div class="row">
<div class="ribbon-icon__title col col--md-6">
<p class="ribbon-icon__tagline">Solutions</p>
<p class="h1">Improve the benefits that health care can provide.</p>
<p class="ribbon-icon__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cursus porta rhoncus pharetra amet, consequat ullamcorper vitae sed. Dolor sem tellus nec risus magna.</p>
</div>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Product information4</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D" />
<h3 class="ribbon-icon__item-title">Patient information material3</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102" />
<h3 class="ribbon-icon__item-title">Clinical in-depth studies2</h3>
<p>Clinical trials, safety studies</p>
</div>
</a>
</div>
<div class="row">
<div class="ribbon-icon__title col col--md-6">
<p class="ribbon-icon__tagline">Solutions</p>
<p class="h1">Improve the benefits that health care can provide.</p>
<p class="ribbon-icon__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cursus porta rhoncus pharetra amet, consequat ullamcorper vitae sed. Dolor sem tellus nec risus magna.</p>
</div>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Product information4</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</a>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D" />
<h3 class="ribbon-icon__item-title">Patient information material3</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</a>
</div>
<div class="row">
<div class="ribbon-icon__title col col--md-6">
<p class="ribbon-icon__tagline">Solutions</p>
<p class="h1">Improve the benefits that health care can provide.</p>
<p class="ribbon-icon__description">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cursus porta rhoncus pharetra amet, consequat ullamcorper vitae sed. Dolor sem tellus nec risus magna.</p>
</div>
<a class="ribbon-icon__items--item col col--md-3">
<div>
<img src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF" />
<h3 class="ribbon-icon__item-title">Product information4</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</a>
</div>
</section>
To avoid complications I've not used all of your CSS rules. This is just a bare minimum code to demonstrate the layout. You can polish it further.
there are several ways in which you can implement it,
Using flexbox and set widths
so, we would want to set the width that we want the cards to take a maximum, and for the title, we would set flex-wrap, so when it has no space the line breaks. Eventually, the lines would break so much that it is not readable, but you can adjust the size when the screen gets smaller with media queries.
in this example, the cards and their container have a set width.
#import url('https://fonts.googleapis.com/css2?family=Antonio:wght#100;200;300;400;500;600;700&family=Roboto:wght#300;400;500&display=swap');
* {
box-sizing: border-box;
}
body {
font-family: roboto, sans-serif;
}
.container {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.row {
width: 100vw;
display: flex;
flex-direction: row;
flex-grow: 1;
height: 200px;
justify-content: space-between;
align-items: center;
&__headers {
display: flex;
flex-direction: column;
&__tagline {
font-family: antonio, sans-serif;
font-weight: 800;
font-size: 14px;
line-height: 1.5rem;
}
&__title {
display: flex;
font-weight: 400;
font-size: 24px;
max-width: 80%;
flex-wrap: wrap;
}
}
&__cards {
display: flex;
flex-direction: row;
flex-grow: 1;
justify-content: space-between;
&__card {
width: 200px;
height: 100px;
margin: 0 20px;
background-color: #ef546d;
}
}
}
<div class="container">
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">Solutions</div>
<div class="row__headers__title">Improve the benefits that health care can provide</div>
</div>
<div class="row__cards">
<div class="row__cards__card"></div>
</div>
</div>
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">Solutions</div>
<div class="row__headers__title">Improve the benefits that health care can provide</div>
</div>
<div class="row__cards">
<div class="row__cards__card"></div>
<div class="row__cards__card"></div>
</div>
</div>
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">Solutions</div>
<div class="row__headers__title">Improve the benefits that health care can provide</div>
</div>
<div class="row__cards">
<div class="row__cards__card"></div>
<div class="row__cards__card"></div>
<div class="row__cards__card"></div>
</div>
</div>
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">Solutions</div>
<div class="row__headers__title">Improve the benefits that health care can provide</div>
</div>
<div class="row__cards">
<div class="row__cards__card"></div>
<div class="row__cards__card"></div>
<div class="row__cards__card"></div>
<div class="row__cards__card"></div>
</div>
</div>
</div>
using flexbox and flex-flow - title goes up
we will take advantage of the flexibility of flexbox and will set our row and row__cards flex-flow to row wrap (combination of flex-wrap and flex-direction). this results in the title going above the cards when it runs out of space and in the cards wrapping to a new line when they run out of space. you can take a look here
$title-max-width: 38%; // You can change it to whatever you`d like
$card-size: 200px;
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.container {
width: 100vw;
display: flex;
flex-direction: column;
}
.row {
background-color: coral;
padding: 20px;
display: flex;
flex-flow: row wrap;
align-items: center;
justify-content: space-between;
&__headers {
max-width: $title-max-width;
}
&__cards {
display: flex;
flex-flow: row wrap;
flex-grow: 1;
justify-content: space-evenly;
padding: 20px;
&__card {
background-color: white;
height: $card-size;
width: $card-size;
}
}
}
<div class="container">
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">solutions</div>
<div class="row__headers__title">
Improve the benefits that health care can provide
</div>
</div>
<div class="row__cards">
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
</div>
</div>
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">solutions</div>
<div class="row__headers__title">
Improve the benefits that health care can provide
</div>
</div>
<div class="row__cards">
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
</div>
</div>
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">solutions</div>
<div class="row__headers__title">
Improve the benefits that health care can provide
</div>
</div>
<div class="row__cards">
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
</div>
</div>
<div class="row">
<div class="row__headers">
<div class="row__headers__tagline">solutions</div>
<div class="row__headers__title">
Improve the benefits that health care can provide
</div>
</div>
<div class="row__cards">
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
<div class="row__cards__card">
<div class="row__cards__card__text"></div>
</div>
</div>
</div>
</div>
let me know if it doesn't fit your needs!
I guess it will help.
I use eventlistener on button element because StackOverFlows snippet window calculates Title[h2] width not for a full screen but you can use
window.addEventListener('load', () => {} )
When you change title it will recalculate cards margin-Top
Click resize button please.
This is for 4
const mainContainer = document.querySelector('div');
const headerContainer = document.querySelector('.header-container');
let firstCard = document.querySelectorAll('.card')[0];
let secondCard = document.querySelectorAll('.card')[1];
let thirdCard = document.querySelectorAll('.card')[2];
let fourthCard = document.querySelectorAll('.card')[3];
const btn = document.querySelector('button')
btn.addEventListener('click', () => {
let childCount = mainContainer.childElementCount;
if(childCount == 2){
mainContainer.setAttribute('class','one-item-container')
firstCard.setAttribute('class','card one-item-first-card ')
}
else if(childCount == 3){
mainContainer.setAttribute('class','two-item-container')
firstCard.setAttribute('class','card two-item-first-card ')
secondCard.setAttribute('class','card two-item-second-card ')
}
else if(childCount > 3){
mainContainer.setAttribute("class","more-item-container");
headerContainer.setAttribute("class","more-header-container");
firstCard.setAttribute('class','card more-first-card ');
secondCard.setAttribute('class','card more-second-card');
thirdCard.setAttribute('class','card third-card');
const cardH2Element = document.getElementById('cardTitle')
const titleHeight = parseInt(cardH2Element.offsetHeight);
firstCard.style.marginTop = `${titleHeight + 40}px`
secondCard.style.marginTop = `${titleHeight + 40}px`
thirdCard.style.marginTop = `${titleHeight + 100}px`
if(childCount == 5){
fourthCard.setAttribute('class','card fourth-card');
fourthCard.style.marginTop = `${titleHeight + 100}px`
}
}
})
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
}
body{
min-height: 100vh;
background-color: grey;
display: grid;
place-content: center;
font-family: Arial, Helvetica, sans-serif;
}
h2{
font-weight:100;
font-size: 2rem;
}
h3{
font-size: 1.5rem;
}
img{
height: 60px;
max-width: 100%;
display: block;
}
.one-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: 1fr 1fr;
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.two-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: 2fr 1fr 1fr;
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.more-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(2,1fr);
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.header-container{
padding: 2rem 6rem 0 0;
}
.header-container > * {
margin-bottom: 1rem;
}
.more-header-container{
padding: 2rem 6rem 0 0;
grid-column: 1 / 3;
grid-row: 1;
}
.more-header-container > * {
margin-bottom: 1rem;
}
.card{
margin: 1rem 0;
padding: 0 1rem;
position: relative;
display: flex;
flex-direction: column;
cursor: pointer;
}
.card::before,
.card::after {
content: "";
position: absolute;
inset: 0;
height: 100%;
box-shadow: inset 1.5px 0 var(--c, #e0b9da);
mask: linear-gradient(var(--p, 0deg), #0000 45%, #000 55%);
pointer-events: none;
}
.card::after {
--c: #b6dae7;
--p: 180deg;
}
.card img{
margin-bottom: 2rem;
}
.card h3{
margin-bottom: 1rem;
line-height: 2rem;
}
.card p{
font-size: 0.9rem;
}
.one-item-first-card{
grid-column: 2;
}
.two-item-first-card{
grid-column: 3;
grid-row: 1;
}
.two-item-second-card{
grid-column: 2 / 3;
grid-row: 1;
}
.more-first-card{
margin-bottom: calc(45%) ;
grid-column: 4;
grid-row:1 / 3;
}
.more-second-card{
grid-column: 3 / 4;
grid-row:1 / 3;
}
.third-card{
grid-column: 2 / 3;
grid-row: 1 / 3;
}
.fourth-card{
grid-column: 1 / 2;
grid-row: 1 / 3;
}
button {
position: absolute;
top:5rem;
right:5rem;
padding: 3rem;
}
<div class="container">
<div class="header-container">
<p>Solutions</p>
<h2 id="cardTitle">
Lorem ipsum dolor sit amet consectetur Lorem ipsum dolor sit amet
consectetur adipisicing elit. Iure, tenetur.
</h2>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF"
alt="Product Information"
/>
</div>
<div class="card__text">
<h3>Product Information</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D"
alt="Patient Information"
/>
</div>
<div class="card__text">
<h3>Patient information material</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102"
alt="Clinical Studies second"
/>
</div>
<div class="card__text">
<h3>Clinical Studies</h3>
<p>Clinical trials, safety studies</p>
</div>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102"
alt="Webinars and eLearning"
/>
</div>
<div class="card__text">
<h3>Webinars and eLearning</h3>
<p>
Get insights on pathophysiology, treatment and safety from experts
</p>
</div>
</div>
</div>
<button>Resize</button>
This is for 3
const mainContainer = document.querySelector('div');
const headerContainer = document.querySelector('.header-container');
let firstCard = document.querySelectorAll('.card')[0];
let secondCard = document.querySelectorAll('.card')[1];
let thirdCard = document.querySelectorAll('.card')[2];
let fourthCard = document.querySelectorAll('.card')[3];
const btn = document.querySelector('button')
btn.addEventListener('click', () => {
let childCount = mainContainer.childElementCount;
if(childCount == 2){
mainContainer.setAttribute('class','one-item-container')
firstCard.setAttribute('class','card one-item-first-card ')
}
else if(childCount == 3){
mainContainer.setAttribute('class','two-item-container')
firstCard.setAttribute('class','card two-item-first-card ')
secondCard.setAttribute('class','card two-item-second-card ')
}
else if(childCount > 3){
mainContainer.setAttribute("class","more-item-container");
headerContainer.setAttribute("class","more-header-container");
firstCard.setAttribute('class','card more-first-card ');
secondCard.setAttribute('class','card more-second-card');
thirdCard.setAttribute('class','card third-card');
const cardH2Element = document.getElementById('cardTitle')
const titleHeight = parseInt(cardH2Element.offsetHeight);
firstCard.style.marginTop = `${titleHeight + 40}px`
secondCard.style.marginTop = `${titleHeight + 40}px`
thirdCard.style.marginTop = `${titleHeight + 100}px`
if(childCount == 5){
fourthCard.setAttribute('class','card fourth-card');
fourthCard.style.marginTop = `${titleHeight + 100}px`
}
}
})
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
}
body{
min-height: 100vh;
background-color: grey;
display: grid;
place-content: center;
font-family: Arial, Helvetica, sans-serif;
}
h2{
font-weight:100;
font-size: 2rem;
}
h3{
font-size: 1.5rem;
}
img{
height: 60px;
max-width: 100%;
display: block;
}
.one-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: 1fr 1fr;
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.two-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: 2fr 1fr 1fr;
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.more-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(2,1fr);
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.header-container{
padding: 2rem 6rem 0 0;
}
.header-container > * {
margin-bottom: 1rem;
}
.more-header-container{
padding: 2rem 6rem 0 0;
grid-column: 1 / 3;
grid-row: 1;
}
.more-header-container > * {
margin-bottom: 1rem;
}
.card{
margin: 1rem 0;
padding: 0 1rem;
position: relative;
display: flex;
flex-direction: column;
cursor: pointer;
}
.card::before,
.card::after {
content: "";
position: absolute;
inset: 0;
height: 100%;
box-shadow: inset 1.5px 0 var(--c, #e0b9da);
mask: linear-gradient(var(--p, 0deg), #0000 45%, #000 55%);
pointer-events: none;
}
.card::after {
--c: #b6dae7;
--p: 180deg;
}
.card img{
margin-bottom: 2rem;
}
.card h3{
margin-bottom: 1rem;
line-height: 2rem;
}
.card p{
font-size: 0.9rem;
}
.one-item-first-card{
grid-column: 2;
}
.two-item-first-card{
grid-column: 3;
grid-row: 1;
}
.two-item-second-card{
grid-column: 2 / 3;
grid-row: 1;
}
.more-first-card{
margin-bottom: calc(45%) ;
grid-column: 4;
grid-row:1 / 3;
}
.more-second-card{
grid-column: 3 / 4;
grid-row:1 / 3;
}
.third-card{
grid-column: 2 / 3;
grid-row: 1 / 3;
}
.fourth-card{
grid-column: 1 / 2;
grid-row: 1 / 3;
}
button {
position: absolute;
top:5rem;
right:5rem;
padding: 3rem;
}
<div class="container">
<div class="header-container">
<p>Solutions</p>
<h2 id="cardTitle">
Lorem ipsum dolor sit amet consectetur Lorem ipsum dolor sit amet
consectetur adipisicing elit. Iure, tenetur.
</h2>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF"
alt="Product Information"
/>
</div>
<div class="card__text">
<h3>Product Information</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D"
alt="Patient Information"
/>
</div>
<div class="card__text">
<h3>Patient information material</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102"
alt="Clinical Studies second"
/>
</div>
<div class="card__text">
<h3>Clinical Studies</h3>
<p>Clinical trials, safety studies</p>
</div>
</div>
<!-- <div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-microscope.svg?iar=0&hash=277AE31475485774CD0094CBB39EC102"
alt="Webinars and eLearning"
/>
</div>
<div class="card__text">
<h3>Webinars and eLearning</h3>
<p>
Get insights on pathophysiology, treatment and safety from experts
</p>
</div>
</div>
</div> -->
<button>Resize</button>
And This is for 2
const mainContainer = document.querySelector('div');
const headerContainer = document.querySelector('.header-container');
let firstCard = document.querySelectorAll('.card')[0];
let secondCard = document.querySelectorAll('.card')[1];
let thirdCard = document.querySelectorAll('.card')[2];
let fourthCard = document.querySelectorAll('.card')[3];
const btn = document.querySelector('button')
btn.addEventListener('click', () => {
let childCount = mainContainer.childElementCount;
if(childCount == 2){
mainContainer.setAttribute('class','one-item-container')
firstCard.setAttribute('class','card one-item-first-card ')
}
else if(childCount == 3){
mainContainer.setAttribute('class','two-item-container')
firstCard.setAttribute('class','card two-item-first-card ')
secondCard.setAttribute('class','card two-item-second-card ')
}
else if(childCount > 3){
mainContainer.setAttribute("class","more-item-container");
headerContainer.setAttribute("class","more-header-container");
firstCard.setAttribute('class','card more-first-card ');
secondCard.setAttribute('class','card more-second-card');
thirdCard.setAttribute('class','card third-card');
const cardH2Element = document.getElementById('cardTitle')
const titleHeight = parseInt(cardH2Element.offsetHeight);
firstCard.style.marginTop = `${titleHeight + 40}px`
secondCard.style.marginTop = `${titleHeight + 40}px`
thirdCard.style.marginTop = `${titleHeight + 100}px`
if(childCount == 5){
fourthCard.setAttribute('class','card fourth-card');
fourthCard.style.marginTop = `${titleHeight + 100}px`
}
}
})
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
}
body{
min-height: 100vh;
background-color: grey;
display: grid;
place-content: center;
font-family: Arial, Helvetica, sans-serif;
}
h2{
font-weight:100;
font-size: 2rem;
}
h3{
font-size: 1.5rem;
}
img{
height: 60px;
max-width: 100%;
display: block;
}
.one-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: 1fr 1fr;
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.two-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: 2fr 1fr 1fr;
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.more-item-container{
display: grid;
max-width: 1100px;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(2,1fr);
background-color: beige;
padding: 0 3rem;
border-radius: 2rem;
}
.header-container{
padding: 2rem 6rem 0 0;
}
.header-container > * {
margin-bottom: 1rem;
}
.more-header-container{
padding: 2rem 6rem 0 0;
grid-column: 1 / 3;
grid-row: 1;
}
.more-header-container > * {
margin-bottom: 1rem;
}
.card{
margin: 1rem 0;
padding: 0 1rem;
position: relative;
display: flex;
flex-direction: column;
cursor: pointer;
}
.card::before,
.card::after {
content: "";
position: absolute;
inset: 0;
height: 100%;
box-shadow: inset 1.5px 0 var(--c, #e0b9da);
mask: linear-gradient(var(--p, 0deg), #0000 45%, #000 55%);
pointer-events: none;
}
.card::after {
--c: #b6dae7;
--p: 180deg;
}
.card img{
margin-bottom: 2rem;
}
.card h3{
margin-bottom: 1rem;
line-height: 2rem;
}
.card p{
font-size: 0.9rem;
}
.one-item-first-card{
grid-column: 2;
}
.two-item-first-card{
grid-column: 3;
grid-row: 1;
}
.two-item-second-card{
grid-column: 2 / 3;
grid-row: 1;
}
.more-first-card{
margin-bottom: calc(45%) ;
grid-column: 4;
grid-row:1 / 3;
}
.more-second-card{
grid-column: 3 / 4;
grid-row:1 / 3;
}
.third-card{
grid-column: 2 / 3;
grid-row: 1 / 3;
}
.fourth-card{
grid-column: 1 / 2;
grid-row: 1 / 3;
}
button {
position: absolute;
top:5rem;
right:5rem;
padding: 3rem;
}
<div class="container">
<div class="header-container">
<p>Solutions</p>
<h2 id="cardTitle">
Lorem ipsum dolor sit amet consectetur Lorem ipsum dolor sit amet
consectetur adipisicing elit. Iure, tenetur.
</h2>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-pills.svg?iar=0&hash=1FDCEF23CA8F9B5C6E1327B9A6FD4DAF"
alt="Product Information"
/>
</div>
<div class="card__text">
<h3>Product Information</h3>
<p>Learn about safety, administration, efficacy and more</p>
</div>
</div>
<div class="card">
<div class="card__image">
<img
src="/-/jssmedia/Eisai-Emea/Shared/Icons/icon-documents.svg?iar=0&hash=13316F3944BF062DA0708F1A38BDFF3D"
alt="Patient Information"
/>
</div>
<div class="card__text">
<h3>Patient information material</h3>
<p>Handouts, treatment guides, patient support material</p>
</div>
</div>
</div>
<button>Resize</button>

How can I make my code look like the screenshot? http://prntscr.com/pqrax8

I am having trouble getting my code to look like the one provided by the link.
http://prntscr.com/pqrax8 If anyone could help me to do that, that would be greatly appreciated and helpful. Thank you in advance. Thank you in advance.
.testimonials {
font-family: 'Roboto Slab', serif;
max-width: 250px;
border-radius: 40px;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
padding: 20px;
margin: 20px 0 0 0;
position: relative;
top: 20em;
left: 100px;
background-color: #fff;
}
.ellipse {
position: static;
max-width: 4em;
vertical-align: middle;
padding-right: 1em;
}
.test {
padding-right: 1em;
vertical-align: middle;
line-height: 20px;
text-align: right;
}
h2 {
color: #60AF64;
text-align: right;
}
<body>
<div class="greensidebox">
<div class="testimonials">
<h2>Judith Cooper</h2>
<img class="ellipse" src="images/Ellipse.png" alt="testimonialpic1">
<div class="test">Lorem ipsum dolor sit amet.Sagittis convallis ligula metus.</div>
</div>
<div class="testimonials">
<h2>Julie Howard</h2>
<img class="ellipse" src="images/Ellipse-1.png" alt="testimonialpic1">
<div class="test">Lorem ipsum dolor sit amet. Sagittis convallis ligula metus.</div>
</div>
<div class="testimonials">
<h2>Kevin Adams</h2>
<img class="ellipse" src="images/Ellipse-2.png" alt="testimonialpic1">
<div>Lorem ipsum dolor sit amet. Sagittis convallis ligula metus.</div>
</div>
</div>
</body>
Flexbox...I put that shhh on everything.
* {
padding: 0;
margin: 0;
line-height: 1;
}
.wrapper {
background-color: lime;
padding: 1rem;
width: 320px;
}
.box {
display: flex;
background-color: #FFF;
border-radius: 32px;
padding: 1.5rem 0.5rem;
margin: 1.5rem 0;
box-shadow: 0 8px 4px rgba(0, 0, 0, 0.2)
}
.box img {
border-radius: 50%;
margin-right: 1rem;
}
.box strong {
font-size: 1.25rem;
display: block;
margin-bottom: 0.25rem;
}
<div class="wrapper">
<div class="box">
<img src="https://via.placeholder.com/80">
<div>
<strong>Judas Priest</strong>
<p>I'm made of metal my circuits gleam I am perpetual I keep the country clean</p>
</div>
</div>
<div class="box">
<img src="https://via.placeholder.com/80">
<div>
<strong>Judas Priest</strong>
<p>I'm made of metal my circuits gleam I am perpetual I keep the country clean</p>
</div>
</div>
<div class="box">
<img src="https://via.placeholder.com/80">
<div>
<strong>Judas Priest</strong>
<p>I'm made of metal my circuits gleam I am perpetual I keep the country clean</p>
</div>
</div>
</div>

Align contents symmetrical with the rest of the page

I'm trying to center an image gallery with a lists background symmetrically. No matter the size of the browser. What are some ways I can symmetrically align content
I tried setting a wrapper around the list and the gallery and setting a fixed width but it only changes my image size and not the list background size. I also tried having a float but it changes around everything.
.months {
display: inline-block;
text-align: justify;
color: #808080;
width: 44.4%;
margin-top: 25px;
}
.months ul {
list-style-type: none;
}
.months li {
background-color: #ffffff;
padding: 16px;
border-bottom: 1px solid #808080;
}
.tourCities {
display: inline-block;
width: 260px;
margin: 15px;
background-color: #ffffff;
}
.tourCities img {
width: 100%;
height: auto;
}
http://jsfiddle.net/xza7g439/
I have included a jsfiddle of the code to keep everything neat.
https://imgur.com/a/PnIzxnp This is what I wanted to achieve
https://imgur.com/a/dDt27UE but this is what I get and it doesn't look right hurts my OCD.
You can do this:
CSS
body {
background-color: #000;
box-sizing: border-box;
}
.wrapper{
display: inline-block;
width: 500px; //Set the size here what you want (px, %)
position: relative;
left: 50%;
transform: translateX(-50%);
}
.months {
display: inline-block;
text-align: justify;
color: #808080;
width: 100%;
margin-top: 25px;
}
.months ul {
list-style-type: none;
margin:0;
padding:0;
}
.months li {
background-color: #ffffff;
padding: 16px;
border-bottom: 1px solid #808080;
}
.tourCities {
display: inline-block;
width: calc(50% - 8px);
background-color: #ffffff;
vertical-align: middle;
float: left;
margin: 16px 0px;
}
.cities .tourCities:nth-child(2n+0) {
margin-right:0;
margin-left: 16px; //pixel perfection
}
.tourCities img {
width: 100%;
height: auto;
}
.desc {
text-align: justify;
padding: 5px;
}
.date{
font-weight: 100;
color: #808080;
}
.smlBtn {
color: #ffffff;
background-color: #000000;
border-style: none;
padding: 14px;
}
HTML
<div class="wrapper">
<div class="months">
<ul>
<li>September</li>
<li>October</li>
<li>November</li>
</ul>
</div>
<div class="cities">
<div class="tourCities">
<img src="https://crunchwear.com/wp-content/uploads/2013/07/shop-imgs-front-full.jpg" alt="New york" width="245" height="184">
<div class="desc">
<p>
<b>New York</b>
</p>
<p class="date">Fri 27 Nov 2019</p>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.</p>
<button class="smlBtn">Buy Tickets</button>
</div>
</div>
<div class="tourCities">
<img src="https://crunchwear.com/wp-content/uploads/2013/07/shop-imgs-front-full.jpg" alt="Paris" width="245" height="184">
<div class="desc">
<p>
<b>Paris</b>
</p>
<p class="date">Sat 28 Nov 2019</p>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.</p>
<button class="smlBtn">Buy Tickets</button>
</div>
</div>
<div class="tourCities">
<img src="https://crunchwear.com/wp-content/uploads/2013/07/shop-imgs-front-full.jpg" alt="San Francisco" width="245" height="184">
<div class="desc">
<p>
<b>San Francisco</b>
</p>
<p class="date">Sun 29 Nov 2019</p>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.</p>
<button class="smlBtn">Buy Tickets</button>
</div>
</div>
</div>
</div>
DEMO HERE

Float images to the right of div containing header, text, and link

I'm having trouble floating two images to the right of another div element containing a header, text, and a link. I can get the images to float right to one of these things, but not all three.
.feature1 {
width: 800px;
margin-bottom: 30px;
margin-top: 140px;
text-align: right;
background-color: cyan;
display: inline-block;
overflow:hidden;
}
.featuresimg {
float:right;
}
<main class="features">
<div class="feature1 clearfix">
<div>
<img src="assets/image1.jpg">
<img src="assets/image2.jpg">
</div>
<div>
<h4 class="feature-head">FEATURE</h4>
<h3 class="feature-text">Donec ultrices interdum diam Nam ut est</h3>
SEE MORE
</div>
</div>
Really new to this, so appreciate any help. I've been looking at other people's questions, and can't find an answer that fits what I'm trying to do.
I would suggest using flexbox. It is generally a better way than float of positioning things horizontally. A good guide to this can be found here.
.feature1 {
display: flex;
flex-direction: row;
width: 800px;
margin-bottom: 30px;
margin-top: 140px;
overflow:hidden;
text-align: right;
background-color: cyan;
}
.feature1 > div {
flex: 1;
}
<main class="features">
<div class="feature1 clearfix">
<div>
<h4 class="feature-head">FEATURE</h4>
<h3 class="feature-text">Donec ultrices interdum diam Nam ut est</h3>
SEE MORE
</div>
<div>
<img src="http://via.placeholder.com/350x150">
<img src="http://via.placeholder.com/350x150">
</div>
</div>
Float images to the right
.feature1{
width: 800px;
margin-bottom: 30px;
margin-top: 140px;
text-align: left;
background-color: cyan;
display: block;
overflow:hidden;
}
.feature1 img {
display: block;
margin-right: 10px;
float:right;
height: 100px;
width: 100px;
}
main class="features">
<div class="feature1 clearfix">
<div>
<img src="https://cdn.pixabay.com/photo/2017/01/16/15/18/soap-bubble-1984310__340.jpg">
<img src="https://cdn.pixabay.com/photo/2012/07/07/06/39/bubbles-51675__340.jpg">
</div>
<div>
<h4 class="feature-head">FEATURE</h4>
<h3 class="feature-text">Donec ultrices interdum diam Nam ut est</h3>
SEE MORE
</div>
</div>
</main>

How to remove this horizontal scrollbar in Bootstrap 3

I've got this irritating horizontal scroll on my bootstrap page. Can't figure out what is making it behave like this or what to do about it?
JsFiddle link: http://jsfiddle.net/FatAlbert/cd1syrd9/2/
HTML:
<body>
<div class="wrapper">
<div class="row">
<div class="header">
<div class="container">
<!-- navigation-->
<nav class="navbar navbar-default">
<div class="container-fluid">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">Meny</button>
<a class="navbar-brand" href="#"><img src="xxx" /></a>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Start <span class="sr-only">(current)</span></li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
</div>
</nav><!-- / navigation-->
</div>
</div><!-- / header-->
</div><!-- / container-->
<div class="row">
<div class="first-page-content">
<div class="container">
<img class="img-responsive img-big" src="xx" />
<p>
Lorem ipsum dolor sit amet, arcu nulla. Maecenas congue, felis leo et, pulvinar sollicitudin lacinia libero rhoncus, nam dolor, velit leo ullamcorper massa. Risus netus facilisis tempus mollis, nullam nibh ridiculus potenti donec pulvinar proin. Sit in ultrices sed orci pellentesque, nunc tempor fusce fusce ultrices felis molestie. Lorem nam pellentesque integer urna nam.
</p>
</div>
</div>
</div><!--/first-content-->
</div>
<div class="footer">
<div class="container">
<p class="pull-right">
Some<br />
Info<br />
</p>
</div>
</div><!-- /footer-->
</body>
CSS:
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 160px;
}
h1 {
font-size: 2.5em;
}
h2 {
font-size: 1.5em;
}
p {
font-family: Verdana,Arial,sans-serif;
font-size: 1.05em;
line-height: 1.8;
text-align: justify;
}
a {
color: #0071BB;
font-weight: bold;
}
.wrapper {
}
.footer {
position: absolute;
padding-top: 25px;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here */
height: 160px;
background-color: #5FC8FF;
}
.header .glyphicon-wrench {
margin: 0 3px;
}
.header h4 {
margin-right: 3px;
}
.img-responsive {
display: block;
margin: auto;
}
.img-responsive.img-big {
margin-top: 75px;
}
.navbar {
border: none;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
.navbar-default .navbar-nav > li {
width: 150px;
margin-right: 2px;
}
.navbar-default .navbar-nav > li > a,
.navbar-default .navbar-nav > li > a:hover {
color: #fff;
font-weight: bold;
background-color: #92C7E1;
}
.navbar-default .navbar-nav > li > a:hover {
background-color: #98CEE5;
}
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
color: #fff;
background-color: #98CEE5;
}
a.navbar-brand {
padding: 5px;
}
.row {
}
.alert {
}
.well {
}
.footer p {
font-weight: bold;
color: #FDFDFB;
}
#media (min-width: 992px) {
}
#media (min-width: 768px) {
.first-page-content p {
margin: 75px auto 25px auto;
width: 524px;
}
}
As per Bootstrap 3 documentation:
Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding.
Therefore, add the class container to your .wrapper element.
Updated Example
<div class="wrapper container">
<div class="row">
...
</div>
</div>
As for an explanation, the .row class has -15px margins on each side.
.row {
margin-right: -15px;
margin-left: -15px;
}
The .container class effectively displaces that with the following:
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
In addition to reading the Bootstrap 3 docs, I'd suggest reading the article "The Subtle Magic Behind Why the Bootstrap 3 Grid Works".
Just copy this code to your CSS, it will disable your horizontal scroll bar.
body {overflow-x: hidden;}
Writing:
html, body {
max-width: 100%;
overflow-x: hidden;
}
in your CSS, is a way to solve this issue
Copy and paste this in CSS code
html, body {
overflow-x: hidden;
}
Setting overflow-x: hidden; works but it will affect scrolling events. Putting rows within the container worked for me.
The issue is basically caused due to the parent .container is missing. The solution is that you can add a .no-container class to the row and add margin: 0 to compensate the negative margin of the row class.
See the below CSS and HTML markup code:
.no-container {
margin-left: 0 !important;
margin-right: 0 !important;
}
.row {
border: 1px solid #999;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<!--<div class="container"> Container is commented -->
<div class="row no-container">
<div class="col-md-6 col-xs-6 col-sm-6">column-6</div>
<div class="col-md-6 col-xs-6 col-sm-6">column-6</div>
</div>
<!--</div> Container ends here -->
In my case, I had one container-fluid class div tag in another container-fluid class div tag. Removing one of them fixed the issue.
Try this! It works for me.
.col-12{
padding-right: 0!important;
padding-left: 0!important;
}
.row{
margin-right: 0px;
margin-left: 0px;
}