How can i center icons along with my text/paragraph in react? - html

How can i center my icons like <GrTools size="30px"/> along with my text? I am kind of having issues with some of my styled centering components.
my js:
<div id = 'paragraph' className="container" >
<h1 className='text-center' > Title <b> </b> </h1>
<p id='content' className='lead mb-4'> paragraph</p>
<hr className='col-xs-12 '/>
<p id='content' className='lead mb-4'> paragraph</p>
<GrTechnology className = 'responsive-image' size='30px'/>
<p id='content' className='lead mb-4'> Paragraph</p>
<GrTools size="30px"/>
<p id='content' className='lead mb-4'> Paragraph</p>
</div>
my css file:
div#paragraph{
width: 100%;
margin: 0px auto;
}
p#content{
text-align: center;
width: 100%;
margin: 50px auto;
}

Wrap the paragraph and icon in a div(container) and use flex-box display:flex on the container to align the children(icon & p)
as #man517 suggested this guide more then enough css-tricks.com/snippets/css/a-guide-to-flexbox
note: change the class to className 😉
.container{
display: flex;
}
<div id='paragraph' >
<h1 className='text-center'> Title <b> </b> </h1>
<p id='content' className='lead mb-4'> paragraph</p>
<hr className='col-xs-12 ' />
<div class="container">
<p id='content' className='lead mb-4'> paragraph</p>
<img src="https://img.icons8.com/ios-glyphs/30/000000/cat--v1.png" width='30px' />
</div>
<div class="container">
<img src="https://img.icons8.com/ios-glyphs/30/000000/cat--v1.png" width='30px' />
<p id='content' className='lead mb-4'> paragraph</p>
</div>
<p id='content' className='lead mb-4'> Paragraph</p>
</div>

Related

How to place text over sliding images

Whenever I run this code on the HTML page, it shows the box with the text on the first sliding image for a brief second, then it disappears for some reason. Here is the HTML for the sliding images.
.containerSlider {
position: relative;
}
.text-block {
position: absolute;
bottom: 100px;
right: 150px;
background-color: black;
color: white;
}
<section>
<div id="containerSlider">
<div id="slidingImage">
<img src="https://via.placeholder.com/100" alt="image4">
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
<div id="slidingImage">
<img src="https://via.placeholder.com/100/ffcccc" alt="image1">
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
<div id="slidingImage">
<img src="https://via.placeholder.com/100" alt="image2">
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
<div id="slidingImage">
<img src="https://via.placeholder.com/100/ffcccc" alt="image3">
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
</div>
</section>
and the Javascript for the Slider is
<!-- <script src=“https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js”></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<script>
$(document).ready(function () {
$('#containerSlider').slick({
dots: true,
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 5000,
});
});
</script>
You have to add position:relative to the div you want your text to be placed in. In your case, .containerSlider contains the complete slider but we want to target individual slides which in this case are .slidingImage.
So, after updating your CSS to something like the code below, I believe I got what you wanted.
#slidingImage {
position: relative;
width: fit-content;
}
p {
position: absolute;
bottom: 10%;
background-color: black;
color: white;
}
<section>
<div id="containerSlider">
<div id="slidingImage">
<img src="https://via.placeholder.com/100" alt="image4" />
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
<div id="slidingImage">
<img src="https://via.placeholder.com/100/ffcccc" alt="image1" />
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
<div id="slidingImage">
<img src="https://via.placeholder.com/100" alt="image2" />
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
<div id="slidingImage">
<img src="https://via.placeholder.com/100/ffcccc" alt="image3" />
<div class="text-block">
<p>This is a text to see if this works</p>
</div>
</div>
</div>
</section>
.slidingImage {
height: 100px;
width: 100px;
color: white;
overflow-wrap: break-word;
display: flex;
justify-content:center;
align-items:center
background-repeat: no-repeat;
margin-bottom: 10px
}
<div class="slidingImage" style="background-image: url(https://via.placeholder.com/100)">
<p>This is a text to see if this works</p>
</div>
<div class="slidingImage" style="background-image: url(https://via.placeholder.com/100)">
<p>This is a text to see if this works</p>
</div>
<div class="slidingImage" style="background-image: url(https://via.placeholder.com/100)">
<p>This is a text to see if this works</p>
</div>
<div class="slidingImage" style="background-image: url(https://via.placeholder.com/100)">
<p>This is a text to see if this works</p>
</div>
here

Setting position of custom slider controls (CSS)

I've been making my anime website where people can watch anime for free with subtitles (Bulgarian subtitles, since I'm from Bulgaria). Now I'm remaking it from scratch because I have been using a theme but It didn't have much functionality... Now I'm making the slider for the recently added animes but I want it to be a custom one so I'm making.... the slider controls are not in a position, so I tried with float, flex with float, etc.... Here's a picture where it should belong: click to open the image (important)
Here's the HTML:
<div class="recent-anime">
<!-- Title and Controls -->
<div class="title-controls">
<h1 class="title">Наскоро добавни</h1>
<a><i class="fas fa-angle-left"></i></a>
<a><i class="fas fa-angle-right"></i></a>
</div>
<!-- Anime cards -->
<div class="animecards">
<div class="animecard">
<img src="images/cover.png">
<div class="ani">
<p class="anititle">Anime title</p>
<p class="aniepisode">Episode</p>
</div>
</div>
<div class="animecard ml">
<img src="images/cover.png">
<div class="ani">
<p class="anititle">Anime title</p>
<p class="aniepisode">Episode</p>
</div>
</div>
<div class="animecard ml">
<img src="images/cover.png">
<div class="ani">
<p class="anititle">Anime title</p>
<p class="aniepisode">Episode</p>
</div>
</div>
<div class="animecard ml">
<img src="images/cover.png">
<div class="ani">
<p class="anititle">Anime title</p>
<p class="aniepisode">Episode</p>
</div>
</div>
<div class="animecard ml">
<img src="images/cover.png">
<div class="ani">
<p class="anititle">Anime title</p>
<p class="aniepisode">Episode</p>
</div>
</div>
<div class="animecard ml">
<img src="images/cover.png">
<div class="ani">
<p class="anititle">Anime title</p>
<p class="aniepisode">Episode</p>
</div>
</div>
</div>
</div>
And the CSS:
.title-controls {
display: flex;
flex-direction: row;
font-size: 42px;
margin-bottom: 10px;
}
.title {
font-size: 26px;
}
.animecards {
display: flex;
}
.animecard {
display: block;
float: left;
}
.animecard img {
max-height: 325px;
}
.ml {
margin-left: 15px;
}
.ani {
text-align: center;
}
There's no JS. Still on the HTML and CSS part.
NOTE: This is clean CSS!
justify-content: space-between; on title-controls class will solve the issue shown in image
.title-controls {
display: flex;
flex-direction: row;
font-size: 42px;
margin-bottom: 10px;
justify-content: space-between;
}

Page with multiple columns, horizontal scrolling, no vertical scrolling

I'd like to build a web page that has multiple columns. Within each column there will be boxes containing text; each box will either fit in one column or go to the top of the next column. If there are more columns than fit on the page, there should be horizontal scrolling. There should be no vertical scrolling. Here's an image of what I'd like to achieve:
In the example, box "The title 7" wouldn't fit at the bottom of column 1, so started new column 2. And then when no more new boxes can fit in column 2, they start at the top of column 3.
What I've so far managed to achieve is all the boxes in one column, using this CSS:
.outer {
height: 500px;
overflow-x: scroll;
background: #fc8;
}
h1 {
font-size: 18px;
margin: 1px 0px 3px 0px;
color: #248;
}
p { font-size: 13px; margin: 2px 0px;}
.box {
background: #def;
padding: 3px 6px;
border: 2px solid #369;
margin: 3px 6px;
vertical-align: top;
width: 250px;
}
The boxes are in a div.outer and have this HTML:
<div class='outer'>
<div class='box'>
<h1>The title 1</h1>
<p>Some text here...</p>
</div>
...etc...
</div>
See JS Fiddle for example. Ideally I'd like a solution that's just HTML and CSS, no JavaScript.
You can make use of flexbox layout. The columns will wrap after it reaches the maximum height using flex-flow: column wrap. Make sure you look into the browser support for flexbox.
JSfiddle Demo
.outer {
height: 500px;
overflow: auto;
background: #fc8;
/* Added CSS */
display: flex;
flex-flow: column wrap;
}
h1 {
font-size: 18px;
margin: 1px 0px 3px 0px;
color: #248;
}
p {
font-size: 13px;
margin: 2px 0px;
}
.box {
background: #def;
padding: 3px 6px;
border: 2px solid #369;
margin: 3px 6px;
vertical-align: top;
width: 250px;
}
<div class='outer'>
<div class='box'>
<h1>The title 1</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 2</h1>
<p>
Some different text here...
</p>
</div>
<div class='box'>
<h1>The title 3</h1>
<p>
Some longer text here. Danish croissant. Powder halvah. Tootsie roll topping tiramisu jelly-o fruitcake cheesecake marzipan.
</p>
</div>
<div class='box'>
<h1>The title 4</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 5</h1>
<p>
Some text here. Chocolate cake gummi bears wafer apple pie. Bear claw gummies pie sugar plum jujubes. Liquorice croissant sugar plum danish macaroon.
</p>
</div>
<div class='box'>
<h1>The title 6</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 7</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 8</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 9</h1>
<p>
Some varied text here...
</p>
</div>
<div class='box'>
<h1>The title 10</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 11</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
<div class='box'>
<h1>The title 12</h1>
<p>
Some text here...
</p>
</div>
</div>
You can achieve similar structure using CSS3 column property.
.outer {
height: 500px;
overflow: auto;
background: #fc8;
-webkit-columns: 3;
-moz-columns:3;
columns:3;
-webkit-column-width:250px;
-moz-column-width:250px;
column-width:250px;
-webkit-column-gap:10px;
-moz-column-gap:10px;
column-gap:10px;
}
DEMO

Div not float as expected?

I have an annoying problem with my HTML page.
Here you can see my webpage: http://jgeneration.altervista.org/layout3.html
If you don't resize the window of your browser, you'll see it right, but if you do it then something strange happens. The first three divs of the second row get moved into a kind of new row when the second div of the first row gets bigger.
That's what happens:
Screenshot 1
I want the divs to be like a waterfall like style, so they must adapt their position according to the height of the other ones.
Here's my HTML & CSS.
<!DOCTYPE html>
<html>
<head>
<title>Muzic4U</title>
<link href='https://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
</head>
<body>
<div style="max-width: 100%; background-color: #0099FF; text-align: center; color: #fff; padding: 20px; margin: 0;">
<h1 style="margin: 0;"> Muzic4U </h1>
</div>
<div id="main">
<div class="tab">
<img src="http://cdn.albumoftheyear.org/album/25168-blast-radius.jpg" />
<p class="caption"> <b> Insight </b><br> <i>The Blast Radius</i><br>2004</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="http://static.marapcana.com/wp-content/uploads/2015/05/Orgasmi-Meccanici-cover.jpg" />
<p class="caption"> <b> Alien Army </b><br> <i>Orgasmi Meccanici</i><br>1999</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="http://img.maniadb.com/images/album/187/187420_1_f.jpg" />
<p class="caption"> <b> Surreal & The Sound Providers </b><br> <i>True Indeed</i><br>2003</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b> <br> <i>The Find</i> <br> 2005 </p>
<div class="dw">
Download
</div>
</div>
<span class="clear"></span>
</div>
<style>
body {
font-family: Ubuntu, sans-serif;
padding: 0;
margin: 0;
background-color: #333;
}
/* unvisited link */
a:link {
color: #fff;
}
/* visited link */
a:visited {
color: #fff;
}
/* mouse over link */
a:hover {
color: #fff;
}
/* selected link */
a:active {
color: #fff;
}
img {
display: table-cell;
max-width: 100%;
}
#main {
margin: 0 auto;
padding: 5px 0 0 5px;
max-width: 70%;
}
.tab {
max-width: calc((100% / 5) - 5px);
background-color: #666;
text-align: center;
float: left;
display: inline-block;
margin: 0 5px 5px 0;
}
.dw {
max-width: 100%;
background-color: #000;
padding: 10px;
}
span.clear {
clear: left;
display: block;
}
.caption {
font-size: smaller;
}
</style>
</body>
Thank you for the support.
This happens because when the page gets smaller the text from the third <p class="caption"> needs one more line.
give your .caption following style:
.caption {
font-size: smaller;
min-height: 80px;
}
So all p-tags have the same height and the float will work again. If it happens again when it gets even smaller you maybe need to increase the px-size of min-height. Here is a code snippet:
<!DOCTYPE html>
<html>
<head>
<title>Muzic4U</title>
<link href='https://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
</head>
<body>
<div style="max-width: 100%; background-color: #0099FF; text-align: center; color: #fff; padding: 20px; margin: 0;">
<h1 style="margin: 0;"> Muzic4U </h1>
</div>
<div id="main">
<div class="tab">
<img src="http://cdn.albumoftheyear.org/album/25168-blast-radius.jpg" />
<p class="caption"> <b> Insight </b><br> <i>The Blast Radius</i><br>2004</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="http://static.marapcana.com/wp-content/uploads/2015/05/Orgasmi-Meccanici-cover.jpg" />
<p class="caption"> <b> Alien Army </b><br> <i>Orgasmi Meccanici</i><br>1999</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="http://img.maniadb.com/images/album/187/187420_1_f.jpg" />
<p class="caption"> <b> Surreal & The Sound Providers </b><br> <i>True Indeed</i><br>2003</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b> <br> <i>The Find</i> <br> 2005 </p>
<div class="dw">
Download
</div>
</div>
<span class="clear"></span>
</div>
<style>
body {
font-family: Ubuntu, sans-serif;
padding: 0;
margin: 0;
background-color: #333;
}
/* unvisited link */
a:link {
color: #fff;
}
/* visited link */
a:visited {
color: #fff;
}
/* mouse over link */
a:hover {
color: #fff;
}
/* selected link */
a:active {
color: #fff;
}
img {
display: table-cell;
max-width: 100%;
}
#main {
margin: 0 auto;
padding: 5px 0 0 5px;
max-width: 70%;
}
.tab {
max-width: calc((100% / 5) - 5px);
background-color: #666;
text-align: center;
float: left;
display: inline-block;
margin: 0 5px 5px 0;
}
.dw {
max-width: 100%;
background-color: #000;
padding: 10px;
}
span.clear {
clear: left;
display: block;
}
.caption {
font-size: smaller;
min-height: 80px;
}
</style>
</body>
Marcel's solution is good, another approach however would be to use this bit of css code on your caption:
overflow: hidden;
white-space: nowrap; /* Don't forget this one */
text-overflow: ellipsis;
So that if your text is too long (longer than 4 lines in this case) it will be replaced by '...'. That way you won't get that extra line that breaks your floats.
<!DOCTYPE html>
<html>
<head>
<title>Muzic4U</title>
<link href='https://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
</head>
<body>
<div style="max-width: 100%; background-color: #0099FF; text-align: center; color: #fff; padding: 20px; margin: 0;">
<h1 style="margin: 0;"> Muzic4U </h1>
</div>
<div id="main">
<div class="tab">
<img src="http://cdn.albumoftheyear.org/album/25168-blast-radius.jpg" />
<p class="caption"> <b> Insight </b><br> <i>The Blast Radius</i><br>2004</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="http://static.marapcana.com/wp-content/uploads/2015/05/Orgasmi-Meccanici-cover.jpg" />
<p class="caption"> <b> Alien Army </b><br> <i>Orgasmi Meccanici</i><br>1999</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="http://img.maniadb.com/images/album/187/187420_1_f.jpg" />
<p class="caption"> <b> Surreal & The Sound Providers </b><br> <i>True Indeed</i><br>2003</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b><br> <i>The Find</i><br>2005</p>
<div class="dw">
Download
</div>
</div>
<div class="tab">
<img src="https://pbs.twimg.com/media/COxJmdQWcAAFauN.jpg" />
<p class="caption"> <b> Ohmega Watts </b> <br> <i>The Find</i> <br> 2005 </p>
<div class="dw">
Download
</div>
</div>
<span class="clear"></span>
</div>
<style>
body {
font-family: Ubuntu, sans-serif;
padding: 0;
margin: 0;
background-color: #333;
}
/* unvisited link */
a:link {
color: #fff;
}
/* visited link */
a:visited {
color: #fff;
}
/* mouse over link */
a:hover {
color: #fff;
}
/* selected link */
a:active {
color: #fff;
}
img {
display: table-cell;
max-width: 100%;
}
#main {
margin: 0 auto;
padding: 5px 0 0 5px;
max-width: 70%;
}
.tab {
max-width: calc((100% / 5) - 5px);
background-color: #666;
text-align: center;
float: left;
display: inline-block;
margin: 0 5px 5px 0;
}
.dw {
max-width: 100%;
background-color: #000;
padding: 10px;
}
span.clear {
clear: left;
display: block;
}
.caption {
font-size: smaller;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
</body>
Everytime your text goes on two lines you will get that effect. To improve and to achieve the desired solution the best way is to equal_heights().
1.Include the jQuery library in your project:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
2.Use this script:
$(window).load(function(){
equal_heights();
}).resize(function(){
equal_heights();
});
function equal_heights(){
_max = 0;
$('.tab .caption').removeAttr('style');
$('.tab').each(function(){
_height = $('.caption', this).height();
if (_max < _height) {
_max = _height;
};
});
$('.tab .caption').height(_max);
}
Here is a jsfiddle for it: https://jsfiddle.net/6LLgguq0/
The real solution (for a fixed number n of items per row) is to apply a clear: left; to every nth+1 item:
#main div:nth-of-type(5n+1) {
clear: left;
}

Text center and uneven flow?

Why is my text not centered & why is my is my floats not stacked evenly:
https://jsfiddle.net/t5mLm8p6/2/
<H1 class="header-text"> SPECIAL COLORSHIFTING RED/CYAN INLAY FROM REDA </H1>
<div class="images-on-left-side" >
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_02_1.jpg" width="577" height="417" />
</div>
<div class="images-on-right-side" >
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_03.jpg" width="623" height="417" />
</div>
<H1 class="header-text"> FUNKY URBAN INLAY FROM ZEGNA REDA</H1>
<div class="images-on-left-side" >
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_06_1.jpg" width="623" height="416" />
</div>
<div class="images-on-right-side" >
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_05.jpg" width="577" height="416" />
</div>
<H1 class="header-text"> CLASSIC BLUE PATTERN FROM VITALE BARBERIS</H1>
<div class="images-on-left-side" >
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_08.jpg" width="575" height="416" />
</div>
<div class="images-on-right-side" >
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_09.jpg" width="625" height="417" />
</div>
I try to make the divs 6 divs/images stand side by side:
Like here: http://postimg.org/image/urstgg0s7/
But the next text a margin options makes it uneven for some reason.
Wrap your divs in a row. It should be like this--
.row {
border: 1px solid red
}
.row h1 {
text-align: center
}
.row div {
display: inline-block;
width: 290px;
}
.row div > img {
width: 100%
}
<div class="row">
<H1 class="header-text"> SPECIAL COLORSHIFTING RED/CYAN INLAY FROM REDA </H1>
<div class="images-on-left-side">
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_02_1.jpg" width="577" height="417" />
</div>
<div class="images-on-right-side">
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_03.jpg" width="623" height="417" />
</div>
</div>
<div class="row">
<H1 class="header-text"> FUNKY URBAN INLAY FROM ZEGNA REDA</H1>
<div class="images-on-left-side">
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_06_1.jpg" width="623" height="416" />
</div>
<div class="images-on-right-side">
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_05.jpg" width="577" height="416" />
</div>
</div>
<div class="row">
<H1 class="header-text"> CLASSIC BLUE PATTERN FROM VITALE BARBERIS</H1>
<div class="images-on-left-side">
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_08.jpg" width="575" height="416" />
</div>
<div class="images-on-right-side">
<img src="http://www.stock11.ch/media/wysiwyg/inlays/Landingpage_1200pix_inlay-page_09.jpg" width="625" height="417" />
</div>
</div>
\