Centering a block of images - html

Need some help with centering a block of images. Here is an image of how I want it to look like. I've tried margin: 0, auto; and having various margins but it doesnt seem to work.
Any ideas and i would be most grateful!
http://jsfiddle.net/tcd1s7xm/
h1 {
padding-top: 3%;
padding-bottom: 3%;
text-transform: uppercase;
color: #58585B;
font-weight: 500;
text-align: center;
font-size: 24px;
}
p {
max-width: 80%;
min-height: auto;
font-size: 14.5px;
color: #58595B;
line-height: 2em;
font-weight: 300;
text-align: center;
letter-spacing: 0.05em;
display: block;
margin-left: auto;
margin-right: auto;
text-transform: uppercase;
}
.break {
padding-bottom: 3%;
}
.info-wrap {
background-color: #EDEDED;
}
.info-wrap img {
display: block;
margin-left: auto;
margin-right: auto
}
.work {
}
.posts {
display: inline-block;
}
.work-img {
padding: 0;
}
<div class="work">
<div class="row">
<h1>My Work</h1>
</div>
<div class="posts">
<div class="row">
<div class="large-6 columns work-img"><img alt=
"People Portraits" src="img/people.png"></div>
<div class="large-6 columns work-img"><img alt="Murals"
src="img/murals.png"></div>
</div>
<div class="row">
<div class="large-6 columns work-img"><img alt=
"Animal Portraits" src="img/animal.png"></div>
<div class="large-6 columns work-img"><img alt=
"Canvas Paintings" src="img/canvas.png"></div>
</div>
<div class="row">
<div class="large-6 columns work-img"><img alt="Surface Design"
src="img/surface.png"></div>
<div class="large-6 columns work-img"><img alt=
"Tromp L'oeil" src="img/tromp.png"></div>
</div>
</div>
<div class="break"></div>

Are you using Foundation 5? Because if you are, you should probably nest the images in a large-12 div. And I think there are too many rows. For example you could try:
<div class="posts">
<div class="row">
<div class="large-12">
<div class="large-6 columns work-img"><img alt=
"People Portraits" src="img/people.png"></div>
<div class="large-6 columns work-img"><img alt="Murals"
src="img/murals.png"></div>
</div>
<div class="large-12">
<div class="large-6 columns work-img"><img alt=
"Animal Portraits" src="img/animal.png"></div>
<div class="large-6 columns work-img"><img alt=
"Canvas Paintings" src="img/canvas.png"></div>
</div>
<div class="large-12">
<div class="large-6 columns work-img"><img alt="Surface Design"
src="img/surface.png"></div>
<div class="large-6 columns work-img"><img alt=
"Tromp L'oeil" src="img/tromp.png"></div>
</div>
</div>
</div>
And then maybe try margin: 0 auto on work image in CSS, or if that doesn't work try putting a class on the large-12 by adding the class name in front of large-12, and do the margin: 0 auto. It's kinda difficult without the images in the jsfiddle.

You could try a combination of display: inline-block and text-align: center to achieve what you want.
For example:
HMTL:
<div class="wrapper">
<div class="row">
<div class="image">
<!-- image link and etc -->
</div>
<div class="image">
<!-- image link and etc -->
</div>
</div>
<div class="row">
<div class="image">
<!-- image link and etc -->
</div>
<div class="image">
<!-- image link and etc -->
</div>
</div>
<div class="row">
<div class="image">
<!-- image link and etc -->
</div>
<div class="image">
<!-- image link and etc -->
</div>
</div>
</div>
CSS:
.wrapper {
text-align: center;
}
.wrapper .row {
display: inline-block
}

Related

boostrap 4 Equal heights not working

What is the way of making div's have equal heights within the row?
it says everywhere that bootstrap4 is flex by default, but it doesn't work for some unknown reason
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="content" >
<div class="sub_title"> HISTORY </div>
<div class="desc"> Sometext </div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-sm-6 col-md-6 col-lg">
<div class="content">
<div class="sub_title">
<div class="number"> 2012 </div>
</div>
<div class="desc"> some other text </div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6 col-lg ">
<div class="content">
<div class="sub_title">
<div class="number"> 2014 </div>
</div>
<div class="desc"> More text </div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-6 col-lg ">
<div class="content">
<div class="sub_title">
<div class="number"> 2017 </div>
</div>
<div class="desc"> Text here too </div>
</div>
</div>
</div>
the scss
.content {
#extend .effect8;
background: white;
margin: 10px;
padding: 10px 30px 20px;
span {
display: block;
p {
font-weight: bold;
}
}
}
.sub_title {
font-size: 1.5em;
font-weight: 700;
text-transform: uppercase;
display: block;
color: $blue;
margin: 10px auto;
}
this is the scss for the content and the sub_title class
If you want .content to be full height on each .col, the content should have height:100%;. I don't know the CSS def of .effect8.
.content {
background: white;
margin: 10px;
padding: 10px 30px 20px;
height: 100%;
span {
display: block;
p {
font-weight: bold;
}
}
}
https://www.codeply.com/go/B4g6TlSDkA
Actually it depend of browser, e.g In Safari it may not work, and also in Internet Explorer may have unwanted behaviors.
If you're really want equal and avoid cross browser issue try JS solution e.g http://brm.io/jquery-match-height/

why am I not able to see the margin property in my html page?

I am trying to design something but even on adding the margin property I am not able to see the changes.
Below is my html code.
.side {
background-color: teal;
display: inline;
padding: 7px;
margin-top: 20px;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>
Use display: inline-block; instead of just display: inline;, because margin-top and margin-bottom does not work with inline elements
.side {
background-color: teal;
display: inline-block;
padding: 7px;
margin-top: 20px;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>
You could either try this or change inline to block or inline-block
.side {
background-color: teal;
display: inline;
padding: 7px;
line-height: 400%;
}
<div>
<span>Task Managment To-do list</span>
</div>
<div class="row">
<div class="col s3 offset-s1">
<header class="side" id="day">Date Section</header>
</div>
<div class="col s2 offset-s3">
<header class="side">
Navigations
</header>
</div>
</div>

Bulma - How to put image and text inline

I want text on right and image on left and vice-versa with vertically centered both.
It should look like as follows
Image
Structure
<section>
<div class="columns">
<div class="column is-7">
<!-- Image -->
</div>
<div class="column is-5">
<!-- My hero -->
</div>
</div>
</section>
<section>
<div class="columns">
<div class="column is-5">
<!-- My hero -->
</div>
<div class="column is-7">
<!-- Image -->
</div>
</div>
</section>
In total
(Change CSS according to your needs)
.myBg {
background-color: #273238;
color: white;
border: 1px solid white;
}
.myHero .hr {
display: inline-block;
width: 100px;
height: 15px;
background: white;
border-radius: 20px;
margin-bottom: 15px;
}
.myHero h1 {
font-size: 50px
}
.myHero.hero-right {
padding-right: 100px;
text-align: right;
}
.myHero.hero-left {
padding-left: 100px;
}
#media(max-width: 768px) {
.myHero {
padding: 100px 50px !important;
//text-align: left !important;
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css">
<section class="myBg">
<div class="columns is-vcentered">
<div class="column is-7">
<figure class="image is-4by3">
<img src="https://i.stack.imgur.com/WpMdM.png" alt="">
</figure>
</div>
<div class="column is-5">
<div class="myHero hero-right">
<div class="hr"></div>
<h1>BOOST</h1>
<ul>
<li>This is the cooles thing.</li>
<li>I am gonna do in my entire life. Awesome!</li>
<li>Achievements are good as heaven. I want it soon.</li>
</ul>
</div>
</div>
</div>
</section>
<section class="myBg">
<div class="columns is-vcentered">
<div class="column is-5">
<div class="myHero hero-left">
<div class="hr"></div>
<h1>BOOST</h1>
<ul>
<li>This is the cooles thing.</li>
<li>I am gonna do in my entire life. Awesome!</li>
<li>Achievements are good as heaven. I want it soon.</li>
</ul>
</div>
</div>
<div class="column is-7">
<figure class="image is-4by3">
<img src="https://i.stack.imgur.com/WpMdM.png" alt="">
</figure>
</div>
</div>
</section>

How to vertically align the items in the div?

.features {
background-color: #0375b4;
padding: 40px 100px;
float: left;
width: 100%;
}
.features img {
width: 100px;
}
.features-content {
text-align: center;
}
.features-content h1 {
font-size: 24px;
color: #ffffff;
text-transform: uppercase;
margin-top: 10px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="features">
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="features-content">
<img src="https://image.flaticon.com/teams/slug/freepik.jpg" alt="Compass Logo">
<h1>Adventure</h1>
</div>
</div>
<div class="col-sm-4">
<div class="features-content">
<img src="https://image.flaticon.com/teams/slug/freepik.jpg" alt="Compass Logo">
<h1>Fun & Safety</h1>
</div>
</div>
<div class="col-sm-4">
<div class="features-content">
<img src="https://image.flaticon.com/teams/slug/freepik.jpg" alt="Compass Logo">
<h1>Impeccable Service</h1>
</div>
</div>
</div>
</div>
</div>
The items in the div are not vertically aligned . How do I properly align the items in the middle of the div? The picture in the last div is smaller than the pictures in other div so it has gone up. how to put all the pictures in the middle?
This can be achieved by specifying the desired image height (that of the other two images) to the img dom element.
In this case, we apply the following CSS rules to .features-content img
.features-content img {
object-fit: none;
width: 100%;
height: 150px;
}
Complete example
.features {
background-color: #0375b4;
padding: 40px 100px;
float: left;
width: 100%;
}
.features img {
width: auto;
}
.features-content {
text-align: center;
}
.features-content h1 {
font-size: 24px;
color: #ffffff;
text-transform: uppercase;
margin-top: 10px;
}
.features-content img {
object-fit: none;
width: 100%;
height: 150px;
}
<!-- Latest compiled and minified Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="features">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="features-content">
<img src="http://via.placeholder.com/150x150" alt="Compass Logo">
<h1>Adventure</h1>
</div>
</div>
<div class="col-md-4">
<div class="features-content">
<img src="http://via.placeholder.com/150x150" alt="Compass Logo">
<h1>Fun & Safety</h1>
</div>
</div>
<div class="col-md-4">
<div class="features-content">
<img src="http://via.placeholder.com/150x100" alt="Compass Logo">
<h1>Impeccable Service</h1>
</div>
</div>
</div>
</div>
</div>
Click the full screen button on the upper-right portion of the code snippet in order to see a wider view with items side-by-side; as shown in your example screenshot.
you can use following css property -
vertical-align: middle;
You can check in detail on here
Add vertical-align for images, and margin:0 auto; for div container.
.features{
background-color: #0375b4;
padding:40px 100px;
float: left;
width: 100%;
}
img{
width: auto;
vertical-align:middle;
}
.features-content{
text-align: center;
width:100%;
display:inline-block;
margin:0 auto;
}
.features-content h1{
font-size:12px;
margin:0;
text-transform: uppercase;
}
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="features-content">
<img src="images/compass.png" alt="Compass Logo">
<h1>Adventure</h1>
</div>
</div>
<div class="col-md-4">
<div class="features-content">
<img src="images/tube.png" alt="Compass Logo">
<h1>Fun & Safety</h1>
</div>
</div>
<div class="col-md-4">
<div class="features-content">
<img src="images/diamond.png" alt="Compass Logo">
<h1>Impeccable Service</h1>
</div>
</div>
</div>
</div>
If you are using Bootstrap 4 just add d-flex align-items-center to row class to align vertically center.
In your case,
the third column h1 text length is grater when compare to other two so there is some issue in the design.
features{
background-color: #0375b4;
padding:40px 100px;
float: left;
width: 100%;
}
.features img{
width: auto;
}
.features-content{
text-align: center;
}
.features-content h1{
font-size: 24px;
color: #000;
text-transform: uppercase;
margin-top: 10px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="features">
<div class="container">
<div class="row d-flex align-items-center">
<div class="col-md-4">
<div class="features-content">
<img src="https://dummyimage.com/70x70/000/fff" alt="Compass Logo">
<h1>Adventure</h1>
</div>
</div>
<div class="col-md-4">
<div class="features-content">
<img src="https://dummyimage.com/70x70/000/fff" alt="Compass Logo">
<h1>Fun & Safety</h1>
</div>
</div>
<div class="col-md-4">
<div class="features-content">
<img src="https://dummyimage.com/70x70/000/fff" alt="Compass Logo">
<h1>Impeccable Service</h1>
</div>
</div>
</div>
</div>
</div>

Mobile Responsive section

I have a bit of an issue with a site I am creating. I need an alternative of float: left; for these icons. below I will upload two screenshots of the mobile screen and the computer screen.
Computer Size
Mobile Size
This is my code:
.featureIcon {
width: 70px;
float: left;
}
.featureRowSplit {
padding-bottom: 30px;
padding-top: 20px;
}
.featureText {
font-family: 'Lato', sans-serif;
color: #146eff;
margin-left: 80px;
}
<div class="row">
<div class="col-md-8">
<div class="row featureRowSplit">
<div class="col-md-4">
<img src="img/FeatureIcons/1.png" class="featureIcon">
<h3 class="featureText">Cheap</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/2.png" class="featureIcon">
<h3 class="featureText">Friendly</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/3.png" class="featureIcon">
<h3 class="featureText">Clean Code</h3>
</div>
</div>
<div class="row">
<div class="col-md-4">
<img src="img/FeatureIcons/4.png" class="featureIcon">
<h3 class="featureText">Quick</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/5.png" class="featureIcon">
<h3 class="featureText">Helpful</h3>
</div>
<div class="col-md-4">
<img src="img/FeatureIcons/6.png" class="featureIcon">
<h3 class="featureText">Reliable</h3>
</div>
</div>
</div>
<div class="col-md-4">
</div>
</div>
Best Regards,
Ben J
Do want them to align in one column? If so, you can set the whole thing in an unordered list and put the image and header in there. For the css, put list-style-type:none;for the unordered list, and put display:block;and float:left; for the actual li elements.