how to align the height of each column to make them all equal ? I followed the rules from the page: https://www.w3schools.com/howto/howto_css_equal_height.asp, using the properties display:flex and flex: 1, but unfortunately this does not work in my case. Is it affected by the fact that each of these columns is additionally wrapped in bootstrap classes col-12 col-lg-3 ?
HTML code:
<section class="bg-bright container-fluid text-center px-4 py-5">
<div class="row">
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="<?php echo get_theme_file_uri( 'assets/img/dzieło.png' ); ?>" class="cards__img img-fluid" alt="...">
<p class="cards__text">Kompleksowa obsługa klienta</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="<?php echo get_theme_file_uri( 'assets/img/dzieło.png' ); ?>" class="cards__img img-fluid" alt="...">
<p class="cards__text">Dbałość o najmniejsze detale</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="<?php echo get_theme_file_uri( 'assets/img/dzieło.png' ); ?>" class="cards__img img-fluid" alt="...">
<p class="cards__text">Komfort obsługi urządzeń</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="<?php echo get_theme_file_uri( 'assets/img/dzieło.png' ); ?>" class="cards__img img-fluid" alt="...">
<p class="cards__text">Funkcjonalność</p>
</div>
</div>
</div>
</div>
</section>
CSS code:
.row {
--bs-gutter-x: 1.5rem;
--bs-gutter-y: 0;
display: flex;
flex-wrap: wrap;
margin-top: calc(var(--bs-gutter-y) * -1);
margin-right: calc(var(--bs-gutter-x)/ -2);
margin-left: calc(var(--bs-gutter-x)/ -2);
}
.col-lg-3 {
flex: 0 0 auto;
width: 25%;
}
.cards {
display: flex;
width: 100%;
align-items: stretch;
}
.cards__body {
background-color: red;
box-shadow: rgba(0, 0, 0, 0.05) 0px 8px 20px 0px;
flex: 1;
}
.cards__text {
color: #333;
font-size: 17px;
font-weight: 700;
padding: 1rem;
}
You can use min-height:...
.row {
display:flex;
}
.col-lg-3 {
flex: 0 0 auto;
width: 25%;
}
.cards {
display: flex;
width: 100%;
align-items: stretch;
}
.cards__body {
background-color: red;
box-shadow: rgba(0, 0, 0, 0.05) 0px 8px 20px 0px;
flex: 1;
min-height:300px;
}
.cards__text {
color: #333;
font-size: 17px;
font-weight: 700;
padding: 1rem;
max-width:100%;
}
<section class="bg-bright container-fluid text-center px-4 py-5">
<div class="row">
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzhE83ZD8Aa9uJQhWtZ8EdTB7Wg0NsmHg-7w&usqp=CAU" class="cards__img img-fluid" alt="...">
<p class="cards__text">Kompleksowa obsługa klienta klienta klienta</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzhE83ZD8Aa9uJQhWtZ8EdTB7Wg0NsmHg-7w&usqp=CAU" class="cards__img img-fluid" alt="...">
<p class="cards__text">Dbałość o najmniejsze detale</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzhE83ZD8Aa9uJQhWtZ8EdTB7Wg0NsmHg-7w&usqp=CAU" class="cards__img img-fluid" alt="...">
<p class="cards__text">Komfort obsługi urządzeń</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQzhE83ZD8Aa9uJQhWtZ8EdTB7Wg0NsmHg-7w&usqp=CAU" class="cards__img img-fluid" alt="...">
<p class="cards__text">Funkcjonalność</p>
</div>
</div>
</div>
</div>
</section>
You have not added .row class in your CSS. It should be
.row {
display: flex;
}
And all your divs are of the same height. You just have applied the background-colour to cards__body instead of .col-lg-3 which is the full height div.
For making inner divs of same height you can give .card__body class flex as flex: 0 0 auto;
The 'flex' css property will define what part of the wrapper width the columns can span. Here's a cool playground for Flexbox: https://demos.scotch.io/visual-guide-to-css3-flexbox-flexbox-playground/demos/
Normally the below property should be set to stretch by default, but do try to add this css.
.row {
align-items: stretch;
}
Also if the above doesn't do anything:
.row > div {
height: 100%;
}
(((My version is responsive, please run the code snippet as full page below)))
Wow, this is very tricky with bootstrap. In fact, you don't need to use flexbox to do it and I think using flexbox will break the responsive grid system in mobile view. All you need to do is giving the cards and cards__body both height: 100%;, it will take up all the vertical space in the grid row. However, that will bring up another issue: no spacing in mobile view and you might find that margin no longer doing the job of spacing out the element for the cards. Luckily, you can still use padding for spacing.
Checkout the code below and compare the changes what I commented out the things you don't need and what I added. Happy coding ;)
.col-lg-3 {
/* flex: 0 0 auto;
width: 25%; */
}
.cards {
/* display: flex; */
/* width: 100%; */
/* align-items: stretch; */
margin: auto;
width: fit-content;
height: 100%;
padding-bottom: 1em;
}
.cards__body {
background-color: red;
box-shadow: rgba(0, 0, 0, 0.05) 0px 8px 20px 0px;
/* flex: 1; */
height: 100%;
}
.cards__text {
color: #333;
font-size: 17px;
font-weight: 700;
padding: 1rem;
height: 100%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="style.css" />
<title>Static Template</title>
</head>
<body>
<section class="bg-bright container-fluid text-center px-4 py-5">
<div class="row">
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img
src="https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png"
class="cards__img img-fluid"
alt="..."
/>
<p class="cards__text">Kompleksowa obsługa klienta</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img
src="https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png"
class="cards__img img-fluid"
alt="..."
/>
<p class="cards__text">Dbałość o najmniejsze detale</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img
src="https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png"
class="cards__img img-fluid"
alt="..."
/>
<p class="cards__text">Komfort obsługi urządzeń</p>
</div>
</div>
</div>
<div class="col-12 col-lg-3">
<div class="cards">
<div class="cards__body">
<img
src="https://media.sproutsocial.com/uploads/2017/02/10x-featured-social-media-image-size.png"
class="cards__img img-fluid"
alt="..."
/>
<p class="cards__text">Funkcjonalność</p>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
Related
I have so many divs in my website and I want to align them like this with CSS and HTML:
<div class="card" style="width: 18rem; margin: 16px;">
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">Music Name</p>
</div>
</div>
It looks like a Masonry Layout. Try the Below Code and make necessary modifications.
This snippet uses CSS-Grids. You will need to change basic styles on some grid-items to make it look exactly as yours :)
/* CSS reset */
*,
*::after,
*::before {
box-sizing: inherit;
margin: 0;
padding: 0;
}
body {
box-sizing: border-box;
position: relative;
}
html {
font-size: 62.5%;
}
/* Typography --------------------------------------------*/
body {
font-family: 'Helvetica Neue', sans-serif;
font-size: 2rem;
text-align: center;
}
.heading {
margin-bottom: 3rem;
}
.body-text {
font-size: 1.6rem;
line-height: 2.5rem;
margin: 0 auto;
width: 70%;
}
.footer-text {
color: #fff;
font-size: 1.5rem;
}
/* Grids --------------------------------------------*/
.container {
display: grid;
grid-gap: 2rem;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(12, 150px);
margin: 0 auto;
max-width: 90%;
padding: 3rem 0;
}
/* Grid images --------------------------------------------*/
.img {
border-radius: 1rem;
height: 100%;
width: 100%;
object-fit: cover;
}
/* Grid items --------------------------------------------*/
.item-4 {
grid-row: 2/5;
}
.item-5 {
grid-row: 2/6;
}
.item-6 {
grid-row: 2/4;
}
.item-7 {
grid-row: 5/6;
}
.item-8 {
grid-row: 4/6;
}
.item-9 {
grid-row: 6/11;
}
.item-10 {
grid-row: 6/7;
}
.item-11 {
grid-row: 6/9;
}
.item-12 {
grid-row: 7/12;
}
.item-13 {
grid-row: 9/13;
}
.item-14 {
grid-row: 11/13;
}
<body>
<main class="container">
<div class="item-1">
<img class="img" src="https://picsum.photos/500/300" alt="">
</div>
<div class="item-2">
<img class="img" src="https://picsum.photos/500/301" alt="">
</div>
<div class="item-3">
<img class="img" src="https://picsum.photos/500/302" alt="">
</div>
<div class="item-4">
<img class="img" src="https://picsum.photos/500/600" alt="">
</div>
<div class="item-5">
<img class="img" src="https://picsum.photos/500/800" alt="">
</div>
<div class="item-6">
<img class="img" src="https://picsum.photos/500/400" alt="">
</div>
<div class="item-7">
<img class="img" src="https://picsum.photos/500/304" alt="">
</div>
<div class="item-8">
<img class="img" src="https://picsum.photos/500/401" alt="">
</div>
<div class="item-9">
<img class="img" src="https://picsum.photos/500/900" alt="">
</div>
<div class="item-10">
<img class="img" src="https://picsum.photos/500/305" alt="">
</div>
<div class="item-11">
<img class="img" src="https://picsum.photos/500/500" alt="">
</div>
<div class="item-12">
<img class="img" src="https://picsum.photos/500/901" alt="">
</div>
<div class="item-13">
<img class="img" src="https://picsum.photos/500/700" alt="">
</div>
<div class="item-14">
<img class="img" src="https://picsum.photos/500/402" alt="">
</div>
<div class="item-15">
<img class="img" src="https://picsum.photos/500/306" alt="">
</div>
</main>
</body>
you can use grid layout
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
}
add this to a div and children of the div can be adjusted the way you want.
You can stack the card divs using display:flex property. Give display:flex property to your div container and flex-wrap:wrap so that the divs can wrap itself. Use any other flexbox properties you like on container after that. So your code might look like this.
<div class="card-container" style="display:flex;flex-wrap:wrap">
<div class="card" style="width: 18rem; margin: 16px;">
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
</div>
I tried I've fixed it, let me know if it is good for you:
This is also responsive..
<style>
.grid-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 10px;
}
.card {
margin: 5px;
font-size: 30px;
text-align: center;
flex: 1 1 150px; /* Stretching */
}
img{
width: 300px
}
</style>
<body>
<div class="grid-container">
<div class="card" >
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
<div class="card" >
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
<div class="card" >
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
<div class="card" >
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
<div class="card" >
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
<div class="card" >
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
<div class="card" >
<img src="https://mdbootstrap.com/img/new/standard/nature/182.jpg" class="card-img-top" alt="..." />
<div class="card-body">
<p class="card-text">
Music Name
</p>
</div>
</div>
</div>
</body>
I'm trying to create the following layout for one of my web projects. What's the best way to create that using HTML, CSS (Flex)?
I'm struggling with bottom-margin for C & D in Desktop screens, for D in Mobile screens.
As we don't have your code, so based on your question here i provide solution let me know if you have any question..
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-6 mb-5">
<div class="card p-5">
A
</div>
</div>
<div class="col-md-6 mb-5">
<div class="card p-5">
B
</div>
</div>
<div class="col-md-6 mb-5">
<div class="card p-5">
C
</div>
</div>
<div class="col-md-6 mb-5">
<div class="card p-5">
D
</div>
</div>
</div>
</div>
You can do it like this.
.main_container {
display: grid;
grid-template-columns: auto auto;
grid-row-gap: 30px;
grid-column-gap: 30px;
}
.sections {
height: 200px;
text-align: center;
background-color: aqua;
}
/*here for mobiles inside mobile media query put this*/
.main_container {
display: grid;
grid-template-columns: auto;
grid-row-gap: 30px;
grid-column-gap: 30px;
}
<div class="main_container">
<div class="sections">A</div>
<div class="sections">B</div>
<div class="sections">C</div>
<div class="sections">D</div>
</div>
<div class="row">
<div class="col-md-6 col-lg-6 col-xl-6 col-sm-12 col-xs-12">
<p>Write text here A</p>
</div>
<div class="col-md-6 col-lg-6 col-xl-6 col-sm-12 col-xs-12">
<p>Write text here B</p>
</div>
</div>
<div class="cs-t20">
<!-- spacer -->
</div>
</div>
<div class="row">
<div class="col-md-6 col-lg-6 col-xl-6 col-sm-12 col-xs-12">
<p>Write text here C</p>
</div>
<div class="col-md-6 col-lg-6 col-xl-6 col-sm-12 col-xs-12">
<p>Write text here D</p>
</div>
</div>
<div class="cs-t20">
<!-- spacer -->
</div>
</div>
<style>
.cs-t20{
width: 100%;
height: 30px;
}
</style>
Hope it will help you!! All the Best !!
here your go..
.cs-t20 {
width: 100%;
height: 30px;
}
.continer {
width: 100%;
height: 100%;
}
.webpage-page-display {
float: none;
display: table-cell;
}
.webpage-page-column {
z-index: 1;
float: left;
position: relative;
min-height: 1px;
}
.webpage-page-half {
margin-left: 6%;
width: 47%;
}
.webpage-page-first {
margin-left: 0px;
clear: left;
}
.webpage-page-half {
width: 100%;
}
.webpage-page-column {
margin: 0;
margin-bottom: 20px;
width: 100%;
}
#media only screen and (min-width: 320px) and (max-width: 767px) {
.webpage-page_column_table_cell {
display: block;
}
.webpage-page-half {
width: 100%;
}
.webpage-page-column {
margin: 0;
margin-bottom: 20px;
width: 100%;
}
}
<div id="webpage_section">
<div class="container">
<div class="webpage-page-column webpage-page_column_table_cell webpage-page-first webpage-page-half webpage-page-display">
<p>Write text here A</p>
</div>
<div class="webpage-page-column webpage-page_column_table_cell webpage-page-half webpage-page-display">
<p>Write text here B</p>
</div>
<div class="cs-t20"></div>
</div>
</div>
<div id="webpage_section">
<div class="container">
<div class="webpage-page-column webpage-page_column_table_cell webpage-page-first webpage-page-half webpage-page-display">
<p>Write text here C</p>
</div>
<div class="webpage-page-column webpage-page_column_table_cell webpage-page-half webpage-page-display">
<p>Write text here D</p>
</div>
<div class="cs-t20"></div>
</div>
</div>
I am making a page with one .html file and one .css file.
I have incorporated the bootstrap 4 CDN into my html head.
The grid appears properly for the medium screen sizes but it is not resizing when I view on my phone.
I have used bootstrap 4 before with no issues in my react app but the same methods do not seem to be working with plain html and css.
my code can be seen below.
html:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Portfolio</title>
<meta name="description" content="Showcasing my portfolio">
<!-- Latest compiled and minified CSS (bootstrap) -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<nav>
<div class="navLeft">
NAME
</div>
<div class="navRight">
PORTFOLIO
ABOUT
CONTACT
CURRICULUM VITAE
GITHUB PROFILE
</div>
</nav>
<div class="container">
<div class="contentPane">
<div class="nameSection">
<div class="row">
<div class="col-md-4 col-10 mx-auto">
<img src="" alt="NAME">
<h1>NAME</h1>
</div>
</div>
<div class="row">
<div class="col-md-4 col-10 mx-auto">
<div class="underline" class="col-12 mx-auto"></div>
<h4>Front End Developer</h4>
</div>
</div>
</div>
<div class="portfolioSection">
<div class="row">
<div class="col-4 mx-auto">
<h1>PORTFOLIO</h1>
</div>
</div>
<div class="row">
<div class="col-4 mx-auto">
<div class="underline" class="col-12 mx-auto"></div>
<h4>Front End Developer</h4>
</div>
</div>
<div class="row">
<div class="col-10 mx-auto">
<img class="screen" id="kovScreen" src="" alt="King Of Vape Screenshot">
</div>
<div class="col-md-5 col-10 mx-auto">
<img class="screen" id="rgbyScreen" src="" alt="Simon Game Screenshot">
testcontent
</div>
<div class="col-md-5 col-10 mx-auto">
<img class="screen" id="osxsScreen" src="" alt="Naughts and Crosses Screenshot">
testcontent
</div>
<div class="col-md-5 col-10 mx-auto">
<img class="screen" id="pomodoroScreen" src="" alt="Pomodoro Clock Screenshot">
testcontent
</div>
<div class="col-md-5 col-10 mx-auto">
<img class="screen" id="calculatorScreen" src="" alt="Calculator Screenshot">
testcontent
</div>
</div>
</div>
<div class="aboutSection">
<div class="row">
<div class="col-4 mx-auto">
<h1>PORTFOLIO</h1>
</div>
</div>
<div class="row">
<div class="col-4 mx-auto">
<div class="underline" class="col-12 mx-auto"></div>
<h4>Front End Developer</h4>
</div>
</div>
</div>
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
I do have more than 12 columns in some rows but never had an issue with it before, and as I stated earlier, everything works fine on medium screen sizes.
css:
nav {
position: fixed;
top: 0px;
z-index: 1;
display: block;
height: 50px;
width: 100%;
background-color: #A65900;
padding-top: 10px;
box-shadow: 0px 0px 10px 2px rgba(0, 0, 0, 0.68);
}
nav a {
text-decoration: none;
color: white;
padding: 0 0.5em;
display: inline;
}
nav .navLeft {
font-size: 20px;
display: inline;
margin-left: 5rem;
}
nav .navRight {
display: inline;
margin-right: 5rem;
}
.contentPane {
box-shadow: 0px 0px 10px 2px rgba(0, 0, 0, 0.68);
}
.nameSection {
width: 100%;
text-align: center;
background-color: #FFA200;
}
.nameSection img {
margin-top: 90px;
max-height: 200px;
width: 100%;
}
.underline {
display: block;
clear: both;
height: 8px;
background-color: white;
border-radius: 5px;
margin-bottom: 5px;
}
.nameSection h4 {
margin-bottom: 40px;
}
.portfolioSection {
text-align: center;
background-color: #FFEF00;
}
.portfolioSection h1 {
margin-top: 40px;
}
.screen {
width: 100%;
max-height: 200px;
}
Can anybody see what I am doing wrong?
All help is appreciated. Thanks.
See Responsive meta tag in the Bootstrap documentation.
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
You missed out the meta viewport directive so mobile browsers will assume you have not designed a responsive website and will default to scaling for a desktop design instead.
Add the meta element.
On my landing page, we have a "Media Resource" section with links to videos, support materials and social media. Currently, the content in the section shrinks when the window is resized rather than the wanted outcome of stacking.
To be clear, the Videos, Support, and Social are what should be stacking. The heading of the section is perfectly fine.
I've looked through the HTML and CSS for the section but can't seem to pinpoint what's causing them not to stack like desired. Below is the HTML and CSS for what's being worked on.
HTML
<div class="container-fluid no-gutters media-resource-wrapper">
<div class="row">
<div class="col-12 col-lg-4 text-center">
<h2 class="boxheader-lead">Media & Public Relations Resource Center</h2>
</div>
<div class="col-3 col-lg-2">
<img src="~/Images/Video.png" alt="videos" class="img-fluid media-icon video" />
</div>
<div class="col-6 col-lg-4">
<img src="~/Images/Materials.png" alt="support materials" class="img-fluid" />
</div>
<div class="col-3 col-lg-2">
<img src="~/Images/Social.png" alt="social" class="img-fluid media-icon social" />
</div>
</div>
</div>
CSS
.media-resource-wrapper {
background-color: #00b9f2;
padding: 60px 0;
}
.media-resource-wrapper > .row {
margin: 0 10px;
}
.media-resource-wrapper h2 {
margin-bottom: 30px;
color: #fff;
font-weight: bold;
n-bottom: 30px;
color: #fff;
font-weight: bold;
}
/* Media resourse icon positioning */
.media-resource-wrapper .media-icon {
position: relative;
top: 20px;
}
#media (min-width: 992px) {
.health-professionals-block .boxheader-landing {
left: 30px;
margin-top: 250px;
width: 20%;
}
.boxheader-landing h1, .boxheader-landing h2 {
font-size: 1.75em;
}
.boxheader-landing-copy {
font-size: .9em;
}
.media-resource-wrapper h2 {
margin-top: 40px;
border-right: 1px solid #fff;
padding-right: 30px;
}
.media-resource-wrapper .media-icon {
top: 30px;
}
.media-resource-wrapper {
padding: 60px 0 60px 0;
}
}
UPDATE
I made a change that was recommended but the images below shows how it looks by default and then when I shrink.
Standard Size:
Smaller window:
Use standard bootstrap class col-sm-3 and col-sm-6.
Replace the URL with your image and it will stack.
.media-resource-wrapper {
background-color: #00b9f2;
padding: 60px 0;
}
.media-resource-wrapper>.row {
margin: 0 10px;
}
.media-resource-wrapper h2 {
margin-bottom: 30px;
color: #fff;
font-weight: bold;
n-bottom: 30px;
color: #fff;
font-weight: bold;
}
/* Media resourse icon positioning */
.media-resource-wrapper .media-icon {
position: relative;
top: 20px;
}
#media (min-width: 992px) {
.health-professionals-block .boxheader-landing {
left: 30px;
margin-top: 250px;
width: 20%;
}
.boxheader-landing h1,
.boxheader-landing h2 {
font-size: 1.75em;
}
.boxheader-landing-copy {
font-size: .9em;
}
.media-resource-wrapper h2 {
margin-top: 40px;
border-right: 1px solid #fff;
padding-right: 30px;
}
.media-resource-wrapper .media-icon {
top: 30px;
}
.media-resource-wrapper {
padding: 60px 0 60px 0;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" />
<div class="container-fluid no-gutters media-resource-wrapper">
<div class="row">
<div class="col-sm-12 col-lg-4 text-center">
<h2 class="boxheader-lead">Media & Public Relations Resource Center</h2>
</div>
<div class="col-sm-3 col-lg-2">
<img src="https://lh3.googleusercontent.com/gN6iBKP1b2GTXZZoCxhyXiYIAh8QJ_8xzlhEK6csyDadA4GdkEdIEy9Bc8s5jozt1g=w300" alt="videos" class="img-fluid media-icon video" />
</div>
<div class="col-sm-6 col-lg-4">
<img src="https://lh3.googleusercontent.com/gN6iBKP1b2GTXZZoCxhyXiYIAh8QJ_8xzlhEK6csyDadA4GdkEdIEy9Bc8s5jozt1g=w300" alt="support materials" class="img-fluid" />
</div>
<div class="col-sm-3 col-lg-2">
<img src="https://lh3.googleusercontent.com/gN6iBKP1b2GTXZZoCxhyXiYIAh8QJ_8xzlhEK6csyDadA4GdkEdIEy9Bc8s5jozt1g=w300" alt="social" class="img-fluid media-icon social" />
</div>
</div>
</div>
<div class="container-fluid no-gutters media-resource-wrapper">
<div class="row">
<div class="col-12 text-center">
<h2 class="boxheader-lead">Media & Public Relations Resource
Center</h2>
</div>
</div>
<div class="row">
<div class="col-3 ">
<img src="~/Images/Video.png" alt="videos" class="img-fluid media-
icon video" />
</div>
<div class="col-6 ">
<img src="~/Images/Materials.png" alt="support materials"
class="img-fluid" />
</div>
<div class="col-3 ">
<img src="~/Images/Social.png" alt="social" class="img-fluid
media-icon social" />
</div>
</div>
If you want the columns to stack use col-sm- instead...
https://www.codeply.com/go/kQHOYSTEnL
<div class="container-fluid no-gutters media-resource-wrapper">
<div class="row">
<div class="col-12 col-lg-4 text-center">
<h2 class="boxheader-lead">Media & Public Relations Resource Center</h2>
</div>
<div class="col-sm-3 col-lg-2">
<img src="//placehold.it/200" alt="videos" class="img-fluid media-icon video" />
</div>
<div class="col-sm-6 col-lg-4 text-center">
<img src="//placehold.it/200" alt="support materials" class="img-fluid" />
</div>
<div class="col-sm-3 col-lg-2">
<img src="//placehold.it/200" alt="social" class="img-fluid media-icon social" />
</div>
</div>
</div>
As you can see here, the .col- is the smallest breakpoint, so they will continue to shrink horizontally in width. sm is the next size up so they will become full-width, and stack vertically at 576px. If you want the cols to stack at wider widths use col-md-,col-lg- or col-xl-, etc..
<div class="container-fluid no-gutters media-resource-wrapper">
<div class="row">
<div class="col-12 text-center">
<h2 class="boxheader-lead">Media & Public Relations Resource Center</h2>
</div>
<div class="col-3 ">
<img src="~/Images/Video.png" alt="videos" class="img-fluid media-icon video" />
</div>
<div class="col-6 ">
<img src="~/Images/Materials.png" alt="support materials" class="img-fluid" />
</div>
<div class="col-3 ">
<img src="~/Images/Social.png" alt="social" class="img-fluid media-icon social" />
</div>
</div>
I am trying to align horizontaly three elements using the col-sm-4 function but for whatever reason I am missing it is not working. No matter what I do, the items are still displayed aligned to left and vertically. The images are all the same size.
Here's the code snippet:
<section class="container">
<div class="row">
<figure class="col-sm-4">
<p text-align: center>PLAY</p>
<img src="img/m1.jpg"/>
</figure>
<figure class="col-sm-4">
<p text-align: center>LEARN</p>
<img src="img/m2.jpg"/>
</figure>
<figure class="col-sm-4">
<p text-align: center>HELP</p>
<img src="img/m3.jpg"/>
</figure>
</div>
</section>
and the css:
section .row img {
margin: 0 0 30px;
width: 100%;
border: 4px dotted #000;
clear: none;
}
It puzzles me because I have looked over other websites using the same technique and I cannot spot the error. Thanks.
you want like this ?
section .row img {
border: 4px dotted #000;
clear: none;
display:inline-block;
}
.col-sm-4
{
display:inline-block;
}
DEMO HERE
After making a few adjustments, I managed to get your code working (see comments in snippet for details)
/* made the boxes use flexible boxes to lay themselves out in a row */
.flexgrid {
display: flex;
flex-direction: row;
align-items: center;
}
/* fixed css because there were no 'row' elemeents */
/* added the > operand */
section > .col > img {
margin: 30px 0 30px;
width: 50%;
border: 4px dotted #000;
clear: none;
align: center;
}
.col > div, .col > img {
content-align: center
}
<section class="container">
<div class="flexgrid">
<figure class="col">
<!-- change <p> to <div> to avoid newline -->
<div>PLAY</div>
<center>
<img src="img/m1.jpg" />
</center>
</figure>
<figure class="col">
<div>LEARN</div>
<center>
<img src="img/m2.jpg" />
</center>
</figure>
<figure class="col">
<div>HELP</div>
<center>
<img src="img/m3.jpg" />
</center>
</figure>
</div>
</section>
Seems to be an issue with the screen size your using not being specified in the col-- format. I've added col-lg-4 col-md-4 col-sm-4 col-xs-4 as the class to support all screen sizes and it is working perfectly now.
section .row img {
margin: 0 0 30px;
width: 100%;
border: 4px dotted #000;
clear: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<section class="container">
<div class="row">
<figure class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<p text-align: center>PLAY</p>
<img src="img/m1.jpg"/>
</figure>
<figure class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<p text-align: center>LEARN</p>
<img src="img/m2.jpg"/>
</figure>
<figure class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<p text-align: center>HELP</p>
<img src="img/m3.jpg"/>
</figure>
</div>
</section>
You just need to use predefined bootstrap class text-center for <div class=row...:
section .row img {
margin: 0 0 30px;
width: 100%;
border: 4px dotted #000;
clear: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section class="container">
<div class="row text-center">
<figure class="col-xs-4">
<p text-align: center>PLAY</p>
<img src="img/m1.jpg"/>
</figure>
<figure class="col-xs-4">
<p text-align: center>LEARN</p>
<img src="img/m2.jpg"/>
</figure>
<figure class="col-xs-4">
<p text-align: center>HELP</p>
<img src="img/m3.jpg"/>
</figure>
</div>
</section>