Drawing dots between two elements using background pic - html

I'm trying to draw a dotted line between some of my elements without success; I'm trying to accomplish something like the following:
I've looked at a few tutorials to write a line between the elements using the ::after pseudo-element, but I don't see anything happening.
.container {
width: 1066px;
margin: 0 auto;
}
.services {
text-align: center;
max-width: 1080px;
padding: 80px 0;
position: relative;
}
.services .step {
display: inline-block;
width: 152px;
height: 100px;
margin: 50px;
vertical-align: text-top;
}
.services .step .first {
float: right;
}
.services .icons {
background: url("https://www.icracked.com/themes/icracked/images/steps-line.png") repeat-x;
}
<div class="services container">
<div class="step first">
<strong>PASO 1</strong>
<br>
<p>Pon el codigo postal donde te encuentres</p>
</div>
<div class="step">
<strong>PASO 2</strong>
<br>
<p>Dinos qual es el problema</p>
</div>
<div class="step">
<STRONG>PASO 3</STRONG>
<br>
<p>Relajate, nuestro tecnico esta de camino</p>
</div>
<div class="step last">
<STRONG>PASO 4</STRONG>
<br>
<p>Voilà! En menos de una hora tienes el movil arreglado!</p>
</div>
<div class="icons">
<div class="step first">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
<div class="step">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
<div class="step">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
<div class="step last">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
</div>
</div>
http://jsfiddle.net/zhpmahnq/187/

You could try using display: flex; and creating a dotted border on only the top or bottom of a span between images.
.wrapper {
align-items: center;
display: flex;
justify-content: space-between; /* not necessary */
}
.dots {
border-top: 1px dotted black;
width: 100%;
}
https://jsfiddle.net/zhpmahnq/191/

Related

How can I change size of my first and last container in css flexbox?

I'm learning CSS and I have a problem with CSS flexbox and grid.
I wanted to make a grid as shown above but I couldn't. The first and last containers are in different sizes and the others are the same.
Here is my code:
.second-section {
width: 80%;
margin: 10px auto;
display: flex;
flex-direction: row;
position: relative;
flex-wrap: wrap;
}
.category-devider {
width: 80%;
margin: 0 auto;
}
.category-devider p {
font-size: 16px;
}
.category-devider span {
font-size: 18px;
color: #757575;
}
.image-containers {
position: relative;
width: 45%;
margin: 50px auto;
height: 434px;
background-color: #494949;
display: block;
text-align: center;
}
.image-containers h3 {
font-size: 18px;
}
.second-section #img-container img {
height: 100%;
width: 100%;
object-fit: cover;
}
.img1 img {
height: 612px;
}
<div class="second-section">
<div class="image-containers img1">
<img src="/img/apple-watch.jpg" alt="Apple Watch" />
<h3>Rule ratio</h3>
<p>Product design</p>
</div>
<div class="image-containers img2">
<img src="/img/circle.jpg" alt="Situation" />
<h3>Situation</h3>
<p>Visual identity</p>
</div>
<div class="image-containers img3">
<img src="/img/cards.jpg" alt="Cards" />
<h3>Dry air</h3>
<p>User research</p>
</div>
<div class="image-containers img4">
<img src="/img/orange-phone.jpeg" alt="Phone" />
<h3>Vertical</h3>
<p>Product design</p>
</div>
<div class="image-containers img5">
<img src="/img/phone.jpg" alt="Phone" />
<h3>Variable compose</h3>
<p>Product design</p>
</div>
<div class="image-containers img6">
<img src="/img/phone1.jpg" alt="Phone" />
<h3>Scope shift</h3>
<p>Product design</p>
</div>
</div>
You can make array of objects:
{
name: 'name',
title: 'title',
text: 'text'
}
and write:
<div class="second-section">
{array.map((picture, index) => {
<div class={`image-containers img${index}`}>
<img src={`/img/${name}.jpg`} alt="Phone" />
<h3>{picture.title}</h3>
<p>{picture.text}</p>
</div>
})}
</div>

Excess white space on webpage when shrunk

I'm trying to fix when I shrink my website down to 768 pixels there seems to be too much whitespace on the left side, I am unable to work out where it is coming from and how I can fix it, I've tried to remove the default padding and margins, and changed the size of images, but that didn't seem to solve it. I will post some code. Any help would be appreciated.
{
margin: 0px;
padding: 0px;
}
div.item {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
position: relative;
left: 30%;
color: #f8d501;
}
img {
width: 100px;
height: 100px;
border: solid 5px #f8d501;
}
.caption {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
}
div.item-1 {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
padding-top: 40px;
position: relative;
left: 30%;
color: yellow;
}
img {
max-width: 100%;
height: auto;
}
.caption-1 {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
font-family: 'Verdana-bold';
}
h1 {
padding-top: 20px;
color: #fad700;
transform: rotate(-90deg);
font-size: 50px;
}
body {
background-color: #0d395e;
}
.logo-floatRight {
padding-left: 20px;
display: flex;
border: none;
max-width: 100%;
height: auto;
}
.logo-floatLeft {
padding-left: 20px;
display: inline-block;
border: none;
max-width: 100%;
height: auto;
padding: 10px;
}
.flex-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding-left: 35%;
max-width: 600px;
height: auto;
}
.logoHeader{
color: #f8d501;
font-family: "Franklin Gothic Heavy regular"
padding: 10px;
max-width: 100%;
height: auto;
}
.text{
color: #f8d501;
text-align: center;
padding-right: 30px;
}
.logo-floatLefts{
border: none;
width: 100%;
height: auto;
}
#media only screen and (max-width: 768px) {
img {
width: 60%;
}
.logoHeader{
font-size: 15px;
}
.flex-container{
width: 120px;
height: 120px;
}
.caption {
font-size: 12px;
}
.item {
font-size: 15px;
}
}
}
<div class="main">
<div class="showcase-content">
<div class="flex-container">
<img src="https://via.placeholder.com/150" class="logo-floatLeft" alt="logo">
<h2 class="logoHeader">LATIN<br>AMERICAN<br>FILM<br>FESTIVAL IN<br>AUSTRALIA</h2>
<img src="https://via.placeholder.com/150" class="logo-floatRight" alt="logo">
</div>
<div class="item">
BRAZIL
<img src="https://via.placeholder.com/150"/>
<span class="caption">LIFE IS A BITCH<br>Como e Cruel Viver Assim</span>
</div>
<div class="item">
CHILE
<img src="https://via.placeholder.com/150"/>
<span class="caption">BROKEN PANTIES<br>Colzones Ratos</span>
</div>
<div class="item">
COLOMBIA
<img src="https://via.placeholder.com/150"/>
<span class="caption">BAD LUCKY GOAT<br>El Dia De La Cabra</span>
</div>
<div class="item">
COSTA RICA
<img src="https://via.placeholder.com/150"/>
<span class="caption">THE GAZELLE'S DANCE<br>El Baile La Gacela </span>
</div>
<div class="item">
CUBA
<img src="https://via.placeholder.com/150"/>
<span class="caption">FALLEN GODS<br>Los Dioses Rotos</span>
</div>
<br>
<div class="item-1">
ECUADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">QUIJOTES NEGROS<br>Quijotes Negros</span>
</div>
<div class="item-1">
EL SALVADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE PATH OF THE SHADOWS<br>El Camino De Las Sombras</span>
</div>
<div class="item-1">
GAUTEMALA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">WHERE ALL ROADS END<br>Donde Acaban Los Caminos.</span>
</div>
<div class="item-1">
MEXICO
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MARA'AKAME'S DREAM<br>El Sueno Del Mara'akame</span>
</div>
<div class="item-1">
PANAMA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">GRACE & SPLENDOUR<br>Donaire Y Esplendo</span>
</div>
<br>
<div class="item-1">
<h1> FREE<br>EVENT </h1>
</div>
<div class="item-1">
PARAGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE HEIRESSES<br>Las Herederas</span>
</div>
<div class="item-1">
PERU
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">OLD FRIENDS<br>Viejos Amigos</span>
</div>
<div class="item-1">
URUGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE POPES TOILET<br>El Bano Del Papa.</span>
</div>
<div class="item-1">
ARGENTINA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MAN FANCING SOUTHEAST<br>Hombre Mirando al Sudeste</span>
</div>
<div class="text">
<h3>FIND OUT WHEN FESTIVAL IS COMING TO YOUR CITY AT<br>WWW.FACEBOOK.COM/LAFFAUSSIE</h3>
<img src="footer.png" class="logo-floatLefts" alt="logo">
</div>
</div>
</div>
I just removed your extra margin and padding both from the item,item-1, flex-container class, and add only vertical-align and text-align center. And there is no extra margin or padding on the left. all the content remains in the center. Hope it will solve your problem. I also removed img and flex-container class from the media queries.
{
margin: 0px;
padding: 0px;
}
div.item {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
position: relative;
color: #f8d501;
}
img {
width: 100px;
height: 100px;
border: solid 5px #f8d501;
}
.caption {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
}
div.item-1 {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
padding-top: 40px;
position: relative;
color: yellow;
}
img {
max-width: 100%;
height: auto;
}
.caption-1 {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
font-family: 'Verdana-bold';
}
h1 {
padding-top: 20px;
color: #fad700;
transform: rotate(-90deg);
font-size: 50px;
}
body {
background-color: #0d395e;
}
.logo-floatRight {
border: none;
max-width: 100%;
height: auto;
padding: 10px;
}
.logo-floatLeft {
border: none;
max-width: 100%;
height: auto;
padding: 10px;
}
.center-text {
text-align: center;
}
.flex-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
justify-content: center;
}
.logoHeader{
color: #f8d501;
font-family: "Franklin Gothic Heavy regular"
padding: 10px;
max-width: 100%;
height: auto;
}
.text{
color: #f8d501;
text-align: center;
padding-right: 30px;
}
.logo-floatLefts{
border: none;
width: 100%;
height: auto;
}
#media only screen and (max-width: 768px) {
.logoHeader{
font-size: 15px;
}
.caption {
font-size: 12px;
}
.item {
font-size: 15px;
}
}
<div class="main">
<div class="showcase-content">
<div class="flex-container">
<img src="https://via.placeholder.com/150" class="logo-floatLeft" alt="logo">
<h2 class="logoHeader">LATIN<br>AMERICAN<br>FILM<br>FESTIVAL IN<br>AUSTRALIA</h2>
<img src="https://via.placeholder.com/150" class="logo-floatRight" alt="logo">
</div>
<div class="center-text">
<div class="item">
BRAZIL
<img src="https://via.placeholder.com/150"/>
<span class="caption">LIFE IS A BITCH<br>Como e Cruel Viver Assim</span>
</div>
<div class="item">
CHILE
<img src="https://via.placeholder.com/150"/>
<span class="caption">BROKEN PANTIES<br>Colzones Ratos</span>
</div>
<div class="item">
COLOMBIA
<img src="https://via.placeholder.com/150"/>
<span class="caption">BAD LUCKY GOAT<br>El Dia De La Cabra</span>
</div>
<div class="item">
COSTA RICA
<img src="https://via.placeholder.com/150"/>
<span class="caption">THE GAZELLE'S DANCE<br>El Baile La Gacela </span>
</div>
<div class="item">
CUBA
<img src="https://via.placeholder.com/150"/>
<span class="caption">FALLEN GODS<br>Los Dioses Rotos</span>
</div>
</div>
<br>
<div class="center-text">
<div class="item-1">
ECUADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">QUIJOTES NEGROS<br>Quijotes Negros</span>
</div>
<div class="item-1">
EL SALVADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE PATH OF THE SHADOWS<br>El Camino De Las Sombras</span>
</div>
<div class="item-1">
GAUTEMALA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">WHERE ALL ROADS END<br>Donde Acaban Los Caminos.</span>
</div>
<div class="item-1">
MEXICO
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MARA'AKAME'S DREAM<br>El Sueno Del Mara'akame</span>
</div>
<div class="item-1">
PANAMA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">GRACE & SPLENDOUR<br>Donaire Y Esplendo</span>
</div>
</div>
<br>
<div class="center-text">
<div class="item-1">
<h1> FREE<br>EVENT </h1>
</div>
<div class="item-1">
PARAGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE HEIRESSES<br>Las Herederas</span>
</div>
<div class="item-1">
PERU
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">OLD FRIENDS<br>Viejos Amigos</span>
</div>
<div class="item-1">
URUGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE POPES TOILET<br>El Bano Del Papa.</span>
</div>
<div class="item-1">
ARGENTINA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MAN FANCING SOUTHEAST<br>Hombre Mirando al Sudeste</span>
</div>
</div>
<div class="text">
<h3>FIND OUT WHEN FESTIVAL IS COMING TO YOUR CITY AT<br>WWW.FACEBOOK.COM/LAFFAUSSIE</h3>
<img src="footer.png" class="logo-floatLefts" alt="logo">
</div>
</div>
</div>
The padding:0 and margin:0 in the start are for body, which I think you have forgot to write.
If that doesn't solve, check each section by commenting to see which section is bigger in width to leave the white spaces.

Trying to align text and an icon html/css

I am trying to align an icon with some text like this:
however it comes out like this:
.percent {
float: right;
display: inline-block;
position: relative;
}
.card-icon {
float: left;
}
<div class="col-md-4">
<div class="card">
<div class="card-header" id="blue">
<p class="text-center"> Self Managed <img src="app/assets/images/star.png" alt=""> </p>
</div>
<p class="percent"> <img class="card-icon" src="app/assets/images/self.png" alt="Smiley face"> 1% </p>
EDIT ****
With the last answer provided it shows up like this:
.card-icon {float: left;margin-right:10px; }
<style type="text/css">
</style>
<div class="col-md-4">
<div class="card">
<div class="card-header" id="blue">
<p class="text-center"> Self Managed <img src="app/assets/images/star.png" alt=""> </p>
</div>
<div class = "percent">
<img class="card-icon" src="app/assets/images/self.png" alt="Smiley face">
<div class="card-txt"> 1% </div>
</div>
</div>
</div>
Try to use inline-block instead of floats:
.card-icon {
display: inline-block;
vertical-align: middle;
position: relative;
z-index: 1;
}
.card-icon:after {
content: "=";
position: absolute;
right: -16px;
top: 50%;
transform: translateY(-50%);
}
.percent .card-txt:nth-of-type(1) {
text-align: center;
}
.card-txt {
display: inline-block;
vertical-align: middle;
text-align: center;
margin-left: 24px;
}
.block {
display: block;
}
<div class="col-md-4">
<div class="card">
<div class="card-header" id="blue">
<p class="text-center"> Self Managed <img src="app/assets/images/star.png" alt=""> </p>
</div>
<div class="percent">
<img class="card-icon" src="app/assets/images/self.png" alt="Smiley face">
<div class="card-txt">
<span class="block">1%</span>
<span class="block">service tax + VAT</span>
</div>
</div>
</div>
</div>
Sometimes the best solution is an old solution. Using HTML tables allows you to control vertical height with a high level of browser support, and backwards compatibility. Using this approach also make the element responsive. Other solutions that adopt the relative/absolute position method can suffer when resizing browser window size.
table {
margin: 0 auto;
border: 1px solid blue;
}
table tr td {
padding: 10px;
width: 100px;
text-align: center;
vertical-align: middle;
position: relative;
}
table tr .number-cell {
padding-top:10px;
width: 80px;
}
table tr .number-cell .value {
margin-top: 4px;
font-size: 42px;
}
table tr .number-cell .sub-heading {
background: grey
}
table tr .equal-cell {
width: 0px;
}
table tr td img {
width: 100%;
}
<div>
<h1>MY WEBSITE</h1>
<table>
<tr>
<td class="image-cell">
<img src="https://www.fillmurray.com/100/100"/>
</td>
<td class="equal-cell">
<span class="equal">=</span>
</td>
<td class="number-cell">
<div class="value">1%</div>
<div class="sub-heading">service fee</div>
</td>
</tr>
</table>
</div>
.card-icon {float: left;position:relative;z-index:1; }
.card-icon:after {content:"=";position:relative; left:25px;}
.percent .card-txt:nth-of-type(1) {text-align:center;position:relative; left:-55px;}
.card-txt {text-align:center; width:400px;background:#ddd;}
<div class="col-md-4">
<div class="card">
<div class="card-header" id="blue">
<p class="text-center"> Self Managed <img src="app/assets/images/star.png" alt=""> </p>
</div>
<div class = "percent">
<img class="card-icon" src="app/assets/images/self.png" alt="Smiley face">
<div class="card-txt"> 1% </div>
<div class="card-txt"> service tax + VAT </div>
</div>
</div>
</div>
If you want more controle you can use flex styling. An example:
.card {
position: relative;
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
width: 500px;
}
.card-header {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 10px;
background-color: blue;
color: white;
font-size: 24px;
}
.card-content {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: gray;
}
.card-header > img {
position: absolute;
right: 0;
width: 50px;
height: 50px;
}
<div class="card">
<div class="card-header">
<span>Self Managed</span>
<img src="app/assets/images/star.png" alt="">
</div>
<div class="card-content">
<img class="card-icon" src="app/assets/images/self.png" alt="Smiley face">
<span>1%</span>
</div>
</div>

How to have a picture by a header text

I have some text and I want to display a small picture to the left of it, and then on the right side of the text, but I'm not to sure how to do this and make it responsive, so that it all shrinks together when the screen gets smaller.
I'm using bootstrap 3, so far I have:
HTML:
#restaurant-menu img {
width: 100px;
display:inline-block;
vertical-align:top;
}
.border {
display: block;
height: 2px;
margin-top: 30px;
margin-bottom: 30px;
width: 78px;
background: #F8BD23;
margin: 0 auto;
}
h1 {
font-weight: 200;
font-size: 65px;
letter-spacing: 0px;
line-height: 50px;
color: black;
padding-top: 20px;
margin-bottom: 3px;
text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="left">
<img class="img-responsive" src="img/g.png" style="margin: auto;">
</div>
<div class="mid">
<h1>Priserna</h1>
<span class="border"></span>
<p style="text-align: center;margin-top: 15px;">Nedan hittar du alla våra tjänster vi har att erbjuda</p>
</div>
<div class="right">
<img class="img-responsive" src="img/g.png" style="margin: auto;">
</div>
Any help on making 2 images appear on the left side of the text and the right side would be great ,
thanks
Wrap your divs in a container (here flex-container) and give it the attribute of display:flex as shown :
.flex-container {
display: flex; /*Generates a flexbox layout with default flex direction as row */
width: 100%; /* Not really required */
align-items: center; /*Aligns contents vertically */
justify-content: center; /*Aligns contents horizontally */
text-align: center; /*Aligns further text in the center */
}
#restaurant-menu img {
width: 100px;
display: inline-block;
vertical-align: top;
}
.border {
display: block;
height: 2px;
margin-top: 30px;
margin-bottom: 30px;
width: 78px;
background: #F8BD23;
margin: 0 auto;
}
h1 {
font-weight: 200;
font-size: 65px;
letter-spacing: 0px;
line-height: 50px;
color: black;
padding-top: 20px;
margin-bottom: 3px;
text-align: center;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="flex-container">
<div class="left">
<img class="img-responsive" src="https://pbs.twimg.com/profile_images/604644048/sign051.gif" style="margin: auto;">
</div>
<div class="mid">
<h1>Priserna</h1>
<span class="border"></span>
<p style="text-align: center;margin-top: 15px;">Nedan hittar du alla våra tjänster vi har att erbjuda</p>
</div>
<div class="right">
<img class="img-responsive" src="https://pbs.twimg.com/profile_images/604644048/sign051.gif" style="margin: auto;">
</div>
</div>
Using percentages as a width will do the trick, and make it responsive
.left,.mid,.right{
float:left;
}
.left,.right{
width:25%;
}
.left img,.right img{
width:100%;
}
.mid{
width:50%;
}
#restaurant-menu img {
width: 100px;
display:inline-block;
vertical-align:top;
}
.border {
display: block;
height: 2px;
margin-top: 30px;
margin-bottom: 30px;
width: 78px;
background: #F8BD23;
margin: 0 auto;
}
h1 {
font-weight: 200;
font-size: 65px;
letter-spacing: 0px;
line-height: 50px;
color: black;
padding-top: 20px;
margin-bottom: 3px;
text-align: center;
}
<div class="left">
<img class="img-responsive" src="https://vignette.wikia.nocookie.net/geosworld/images/0/09/Toon_link.jpg/revision/latest?cb=20131223183834" style="margin: auto;">
</div>
<div class="mid">
<h1>Priserna</h1>
<span class="border"></span>
<p style="text-align: center;margin-top: 15px;">Nedan hittar du alla våra tjänster vi har att erbjuda</p>
</div>
<div class="right">
<img class="img-responsive" src="https://vignette.wikia.nocookie.net/geosworld/images/0/09/Toon_link.jpg/revision/latest?cb=20131223183834" style="margin: auto;">
</div>
You can try flex like this :
.content {
display: flex;
align-items: center;
justify-content: center;
}
#restaurant-menu img {
width: 100px;
display: inline-block;
vertical-align: top;
}
.border {
display: block;
height: 2px;
margin-top: 30px;
margin-bottom: 30px;
width: 78px;
background: #F8BD23;
margin: 0 auto;
}
h1 {
font-weight: 200;
font-size: 65px;
letter-spacing: 0px;
line-height: 50px;
color: black;
padding-top: 10px;
margin-bottom: 3px;
text-align: center;
}
<div class="content">
<div class="left">
<img class="img-responsive" src="https://lorempixel.com/100/100/" style="margin: auto;">
</div>
<div class="mid">
<h1>Priserna</h1>
<span class="border"></span>
<p style="text-align: center;margin-top: 15px;">Nedan hittar du alla våra tjänster vi har att erbjuda</p>
</div>
<div class="right">
<img class="img-responsive" src="https://lorempixel.com/100/100/" style="margin: auto;">
</div>
</div>
Or a simple inline-block solution :
.content {
text-align: center;
}
.left,
.mid,
.right {
display: inline-block;
vertical-align: top;
}
#restaurant-menu img {
width: 100px;
display: inline-block;
vertical-align: top;
}
.border {
display: block;
height: 2px;
margin-top: 30px;
margin-bottom: 30px;
width: 78px;
background: #F8BD23;
margin: 0 auto;
}
h1 {
font-weight: 200;
font-size: 65px;
letter-spacing: 0px;
line-height: 50px;
color: black;
margin-bottom: 3px;
text-align: center;
}
<div class="content">
<div class="left">
<img class="img-responsive" src="https://lorempixel.com/100/100/" style="margin: auto;">
</div>
<div class="mid">
<h1>Priserna</h1>
<span class="border"></span>
<p style="text-align: center;margin-top: 15px;">Nedan hittar du alla våra tjänster vi har att erbjuda</p>
</div>
<div class="right">
<img class="img-responsive" src="https://lorempixel.com/100/100/" style="margin: auto;">
</div>
</div>
try adding this classes. You can also try to change the width as you wish and make use of media queries to handle the breakpoints to make it responsive.
.left{
width: 10%;
display: inline-block;
}
.mid{
display:inline-block;
}
.right{
width: 10%;
display : inline-block;
}
You can also try this instead
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div class="left">
<img class="img-responsive" src="https://www.w3schools.com/w3css/img_fjords.jpg" style="margin: auto;">
</div>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div class="mid">
<h1>Priserna</h1>
<span class="border"></span>
</div>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<div class="left">
<img class="img-responsive" src="https://www.w3schools.com/w3css/img_fjords.jpg" style="margin: auto;">
</div>
</div>
</div>
<p style="text-align: center;margin-top: 15px;">Nedan hittar du alla våra tjänster vi har att erbjuda</p>
If this isn't the result you wanted, then can you give some more details or reference to what you actually want to achieve

Center <div> inside a <div>

Code: https://jsfiddle.net/z4udfg3o/
I want the divs "caixa" to be centered in the div "produtos". I was able to do it with exact values using margin-left. But I want it to be responsive for other screen sizes so I putted margin-left and margin-right as auto.
Image of desired format:
section {
padding: 2em 0;
display: flex;
justify-content: space-between;
background: antiquewhite;
}
section:before, section:after {
content: "";
}
div {
width: 10em;
height: 10em;
background: silver;
}
<section>
<div></div>
<div></div>
<div></div>
</section>
Use this CSS:
.produtos {
width: 100%;
background: gray;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
.caixa {
width: 27.1%;
height: 250px;
background: darksalmon;
border: 1px solid #000;
float: left;
margin: 0 3%;
}
Like This?
.produtos {
width: 100%;
height: 252px;
background: gray;
text-align: center;
}
.caixa {
width: 250px;
height: 250px;
background: darksalmon;
border: 1px solid #000;
margin: 0 auto;
}
<div class="produtos">
<div class="caixa">
<img src="imagens/croa.png" style="margin-left:60px;">
<p style="text-align:center;">Temos os melhores produtos do mercado! Nossos competidores ajoelham-se perante a nossa qualidade!</p>
</div>
<div class="caixa">
<img src="imagens/dinheiro.png" style="margin-left:60px;">
<p style="text-align:center;">Preços mais baratos do mercado! Promoções 24/7! Se houver ofertas mais baratas diga e fazemos promoção de 0.01€!</p>
</div>
<div class="caixa">
<img href="#" src="imagens/definicoes.png" style="margin-left:60px;">
<p style="text-align:center;">Nosso departamento de apoio ao cliente está ativo 24/7! Resolveremos todas as suas dúvidas!</p>
</div>
</div>
Otherwise, i suggest you to have a look at flexbox
Do it like below:
#wrap {
background: #e7e7e7;
padding: 4px;
text-align: center;
width:100%;
}
#one, #two, #three {
background: #ccc;
display: inline-block;
padding: 20px;
width:20%;
}
<div id="wrap">
<div id="one">I am div 1</div>
<div id="two">I am div 2</div>
<div id="three">I am div 2</div>
</div>
try changing your css like below
.produtos
{
width: 100%;
height: 252px;
background: gray;
text-align: center;
}
.caixa
{
width: 250px;
height: 250px;
background: darksalmon;
border: 1px solid #000;
display: inline-block;
}
The following code sets the orange boxes as display: inline-block which causes them to follow the text flow, which is set to center in the parent container. This allows the boxes to flow depending on available screen space. On wide screens they're all side by side, on smaller ones they're arranged vertically.
I have also modified the HTML in order to get rid of newlines between the boxes. These newlines would cause margins otherwise.
.produtos
{
width: 100%;
background: gray;
text-align: center;
}
.caixa
{
vertical-align: top;
width: 250px;
height: 250px;
background: darksalmon;
border: 1px solid #000;
display: inline-block;
}
<div class="produtos">
<div class="caixa">
<img src="imagens/croa.png" style="margin-left:60px;">
<p style="text-align:center;">Temos os melhores produtos do mercado! Nossos competidores ajoelham-se perante a nossa qualidade!</p>
</div
><div class="caixa">
<img src="imagens/dinheiro.png" style="margin-left:60px;">
<p style="text-align:center;">Preços mais baratos do mercado! Promoções 24/7! Se houver ofertas mais baratas diga e fazemos promoção de 0.01€!</p>
</div
><div class="caixa">
<img href="#" src="imagens/definicoes.png" style="margin-left:60px;">
<p style="text-align:center;">Nosso departamento de apoio ao cliente está ativo 24/7! Resolveremos todas as suas dúvidas!</p>
</div>
</div>
I hope it works for you. I added each div class row for each to so you can set the padding in classemphasized text row.
.produtos
{
width: 100%;
height: 252px;
}
.caixa
{
width: 33%;
height: 100%;
background: darksalmon;
border:1px solid red;
float: left;
}
.row{
height:100%;
padding:0 20px;
}
<div class="produtos">
<div class="caixa">
<div class="row">
<img src="imagens/croa.png">
<p style="text-align:center;">Temos os melhores produtos do mercado! Nossos competidores ajoelham-se perante a nossa qualidade!</p>
</div>
</div>
<div class="caixa">
<div class="row">
<img src="imagens/dinheiro.png">
<p style="text-align:center;">Preços mais baratos do mercado! Promoções 24/7! Se houver ofertas mais baratas diga e fazemos promoção de 0.01€!</p>
</div> </div>
<div class="caixa">
<div class="row">
<img href="#" src="imagens/definicoes.png">
<p style="text-align:center;">Nosso departamento de apoio ao cliente está ativo 24/7! Resolveremos todas as suas dúvidas!</p>
</div> </div>
</div>
There are different ways, but if the boxes are to contain an image or something, then you will need a fixed aspect ratio, that can be accomplished like this:
.wrapper{float:left; width:100%; background-color:deeppink;}
.lil-box{float:left; width:22%; margin:0 5.665%; background-color:bisque;}
.tight-fit{float:left; width:100%; margin-top:100%;}
<div class="wrapper">
<div class="lil-box">
<div class="tight-fit"></div>
</div>
<div class="lil-box">
<div class="tight-fit"></div>
</div>
<div class="lil-box">
<div class="tight-fit"></div>
</div>
</div>
you should balance the width of both divs. "caixa" and "produtos".
I think using % will be responsive for other screeen size too.
Fiddle
Hope Fiddle link help you .