how to fix the interface of this (simple html/css) - html

here is my interface
I have two blocks div.small (include 4 small articles) and article.big. I want the big block to be to the right of the small block, but it's underneath.
*{
font-family: tahoma;
}
div.all{
height: 528px;
width: 824px;
}
article.small{
width: 312px;
height: 82px;
}
div.small{
float: left;
}
img.smallimg{
float: left;
width: 121px;
height: 82px;
}
article.big{
width: 496px;
height: 525px;
}
img.bigimg{
width: 494px;
height: 329px;
}
<div class="all">
<div class="small">
<article class="small">
<img src="small01.jpg" alt="" class = "smallimg">
Link 01
</article>
<article class="small">
<img src="small02.jpg" alt="" class="smallimg">
link 02
</article>
<article class="small">
<img src="small03.jpg" alt="" class="smallimg">
link03
</article>
<article class="small">
<img src="small04.jpg" alt="" class="smallimg">
link04
</article>
<article class="small">
<img src="small02.jpg" alt="" class="smallimg">
link05
</article>
</div>
<article class="big">
<img src="big.jpg" alt="" class="bigimg">
big link
</article>
</div>
I've tried to limit div.all with height = 528px, however, the article.big should've to be to the right, but it's not. My question is: Why's my way wrong?

Notice removal of floats (redundant) and addition of display: flex which displays in child elements as a row by default. The reason your big div is underneath is because the elements being used div are block level elements by default. If they were inline-block they would also align side by side. Cheers!
*{
font-family: tahoma;
}
div.all{
height: 528px;
width: 824px;
display: flex;
}
article.small{
width: 312px;
height: 82px;
}
img.smallimg{
width: 121px;
height: 82px;
}
article.big{
width: 496px;
height: 525px;
}
img.bigimg{
width: 494px;
height: 329px;
}
<div class="all">
<div class="small">
<article class="small">
<img src="small01.jpg" alt="" class = "smallimg">
Link 01
</article>
<article class="small">
<img src="small02.jpg" alt="" class="smallimg">
link 02
</article>
<article class="small">
<img src="small03.jpg" alt="" class="smallimg">
link03
</article>
<article class="small">
<img src="small04.jpg" alt="" class="smallimg">
link04
</article>
<article class="small">
<img src="small02.jpg" alt="" class="smallimg">
link05
</article>
</div>
<article class="big">
<img src="big.jpg" alt="" class="bigimg">
big link
</article>
</div>

Is this what you want? No complicated display: flex; needed
*{
font-family: tahoma;
}
div.all{
height: 528px;
width: 824px;
}
article.small{
width: 312px;
height: 82px;
}
div.small{
float: left;
}
img.smallimg{
float: left;
width: 121px;
height: 82px;
}
article.big{
width: 496px;
height: 525px;
position: absolute;
top:0;
right:0;
}
img.bigimg{
width: 494px;
height: 329px;
}
<div class="all">
<div class="small">
<article class="small">
<img src="small01.jpg" alt="" class = "smallimg">
Link 01
</article>
<article class="small">
<img src="small02.jpg" alt="" class="smallimg">
link 02
</article>
<article class="small">
<img src="small03.jpg" alt="" class="smallimg">
link03
</article>
<article class="small">
<img src="small04.jpg" alt="" class="smallimg">
link04
</article>
<article class="small">
<img src="small02.jpg" alt="" class="smallimg">
link05
</article>
</div>
<article class="big">
<img src="big.jpg" alt="" class="bigimg">
big link
</article>
</div>

Related

padding article elements in html

I'm using an article header to divide up some projects I wish to display:
.project-elem {
background-color: greenyellow;
padding-top: 5rem;
padding-bottom: 5rem;
height: 300px;
}
.projects {
margin: 0;
padding: .7rem;
background-color: #DDCDE8;
font: Asap, sans-serif;
height: 1000px;
}
.project-n {
background-color: green;
text-align: center;
width: 60%;
float: left;
padding: 2.5rem;
}
.img {
background-color: blue;
text-align: center;
padding: 3rem;
margin-left: 40%;
}
<div class="projects" id=#projects>
<h2>My Projects</h2>
<article class="project-elem">
<div class="project-n" id="dictocounter">
<h3>Dictation Counter</h3>
<p>info about proj</p>
<img src="dictocounter1.jpg" alt="Dictocounter in Action">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="calc">
<h3>RPN Calculator</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="RPN Calculator Decoding Input">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="markov">
<h3>Markov Chain Text Generation</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Markov Chain Text Generation">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="audio">
<h3>Song Similarities</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Audio Spectral Analysis">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="tree">
<h3>DFS/BFS Search Tree</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Simple Trees">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
</div>
Yet, even though I pad project-elem explicitly, the actual project-elem articles are not padded (rather, smushed all together into one lime-green blob):
I can tell that there is no padding between the project elements because the outer division (with bkgrd color purple) cannot be seen between each of the lime-green project elements. Why is this the case, and how can I fix this?
Also, how can I make the img class vertically-even with the project-n class?
You might need margin-bottom instead of padding-bottom;
By using padding you don't seperate them, padding works kind of from-inside.
You may read about box-model here to understand this.
Since the project-elem has only padding and not margin, there is no gap between different elements with the class "project-elem"
Change padding to margin for your requirement as shown below:
.project-elem {
background-color: greenyellow;
margin-top: 5rem;
margin-bottom: 5rem;
height: 300px;
}
.projects {
margin: 0;
padding: .7rem;
background-color: #DDCDE8;
font: Asap, sans-serif;
height: 1000px;
}
.project-n {
background-color: green;
text-align: center;
width: 60%;
float: left;
padding: 2.5rem;
}
.img {
background-color: blue;
text-align: center;
padding: 3rem;
margin-left: 40%;
}
Understand the difference between padding and margin. You can refer this: https://stackoverflow.com/a/2189462/12774953
I suggest you to use flex-box for this.
It would be something like this:
html
<html>
<head>
<style>
.project-elem {
background-color: greenyellow;
padding-top: 5rem;
padding-bottom: 5rem;
height: 300px;
display: flex;
justify-content: space-between;
}
.projects {
margin: 0;
background-color: #DDCDE8;
font: Asap, sans-serif;
height: 1000px;
box-sizing: border-box;
}
.project-n {
background-color: green;
text-align: center;
width: 60%;
padding: 2.5rem;
box-sizing: border-box;
}
.img {
background-color: blue;
text-align: center;
padding: 3rem;
box-sizing: border-box;
width: 25%;
}
</style>
</head>
<body>
<div class="projects" id=#projects>
<h2>My Projects</h2>
<article class="project-elem">
<div class="project-n" id="dictocounter">
<h3>Dictation Counter</h3>
<p>info about proj</p>
<img src="dictocounter1.jpg" alt="Dictocounter in Action">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="calc">
<h3>RPN Calculator</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="RPN Calculator Decoding Input">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="markov">
<h3>Markov Chain Text Generation</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Markov Chain Text Generation">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="audio">
<h3>Song Similarities</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Audio Spectral Analysis">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="tree">
<h3>DFS/BFS Search Tree</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Simple Trees">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
</div>
</body>
</html>

jpg images display trouble

I have a very simple HTML / CSS image grid. All photos are different and are inside a <figure> tag. When the images are in jpg file format, when refreshing the page sometimes some of them are repeated or appear distorted, with another ghost image on top or dissappear. This only happens with jpg, not png. Why is this? Is there a solution?
ul { padding: 0; margin: 0; }
figure { margin: 0; }
.grid-item {
float: left;
width: 33%;
}
.tm-img {
max-width: 320px;
width: 100%;
height: auto;
border: none;
margin: 0 auto;
}
.grid-item figure {
position: relative;
overflow: hidden;
text-align: center;
}
.grid-item figure img {
display: block;
max-width: 100%;
}
<ul>
<li>
<div>
<div class="grid-item">
<figure>
<img src="https://stupefied-fermi-29b354.netlify.app/img/01.jpg" alt="Image 01" class="tm-img">
</figure>
</div>
<div class="grid-item">
<figure>
<img src="https://stupefied-fermi-29b354.netlify.app/img/02.jpg" alt="Image 02" class="tm-img">
</figure>
</div>
<div class="grid-item">
<figure>
<img src="https://stupefied-fermi-29b354.netlify.app/img/03.jpg" alt="Image 03" class="tm-img">
</figure>
</div>
<div class="grid-item">
<figure>
<img src="https://stupefied-fermi-29b354.netlify.app/img/04.jpg" alt="Image 04" class="tm-img">
</figure>
</div>
<div class="grid-item">
<figure>
<img src="https://stupefied-fermi-29b354.netlify.app/img/05.jpg" alt="Image 05" class="tm-img">
</figure>
</div>
<div class="grid-item">
<figure>
<img src="https://stupefied-fermi-29b354.netlify.app/img/06.jpg" alt="Image 06" class="tm-img">
</figure>
</div>
</div>
</li>
</ul>
Image repeated
Image disappeared
This is the sample netlify html page
Animation
Refreshing the page multiple times shows the issue.

Put different paragraphs under 3 images in html5,using a class

I have 3 images
HTML:
<img src="cal.png" alt = "calendar" class="info">
<img src="location.png" alt = "location" class="info">
<img src="time.png" alt = "clock" class="info">
CSS:
.info{
height: 15%;
align-content: center;
padding-left: 20%;
}
Now, I want to add text under the 3 images, the text should be centered. It will be 3 different . The 3 images should be on one line.
Please try this code:
Html:
<div class="div-test">
<img src="invoice_logo.png" alt = "calendar" class="info">
<div >YOUR TEXT</div>
</div>
css:
.info{
height: 15%;
align-content: center;
}
.div-test{text-align:center;}
.div-test > span {clear:both;}
From your class remove margin left.If not required then.
You can use the figcaption tag, which is meant for this exact purpose:
div figure {
display: inline-block;
}
.info {
height: 15%;
text-align: center;
}
<div>
<figure>
<img src="http://via.placeholder.com/150x150" alt="calendar" class="info">
<figcaption class="info">Info about image one.</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/150x150" alt="location" class="info">
<figcaption class="info">Info about image two.</figcaption>
</figure>
<figure>
<img src="http://via.placeholder.com/150x150" alt="clock" class="info">
<figcaption class="info">Info about image three.</figcaption>
</figure>
</div>
Your HTML:
<div class="img-with-text">
<img src="yourimage.png" alt="sometext" />
<p>Some text</p>
</div>
Your CSS:
.img-with-text {
text-align: justify;
width: [width of img];
}
.img-with-text img {
display: block;
margin: 0 auto;
}
https://stackoverflow.com/a/1225242/6441416
https://stackoverflow.com/users/7173/jason

CSS floating images in center

So I have that html code with images+title:
<div class="container">
<div class="box"><img src="image1.jpg" class="thumb"><p>Title 1</p></div>
<div class="box"><img src="image2.jpg" class="thumb"><p>Title 2</p></div>
<div class="box"><img src="image3.jpg" class="thumb"><p>Title 3</p></div>
<div class="box"><img src="image4.jpg" class="thumb"><p>Title 4</p></div>
...
<div class="box"><img src="image49.jpg" class="thumb"><p>Title</p></div>
<div class="box"><img src="image50.jpg" class="thumb"><p>Title</p></div>
</div>
And css:
.container {
width:80%;
margin: 0 auto;
}
.box {
display:inline-block;
width:150px;
margin-right:5px;
float:left;
}
With that code I have more "white" space on right, I want to have these pictures in the center for different browser size without setting up width for container.
Is it possible with css?
add to your container class text-align: center; and remove float:left; from box class.
That's what you call a centered, widthless float.
#outer {
/* This is just so you can see that they're centered */
width: 400px;
border: 1px solid black;
overflow: hidden;
}
.centered {
position: relative;
float: left;
left: 50%;
/* This and below is just because I have them stacked */
height: 100px;
padding-bottom: 10px;
clear: left;
}
.centered div {
position: relative;
float: left;
left: -50%;
}
<div id="outer">
<div class="centered">
<div>
<img src="http://placehold.it/200x100" alt="" />
</div>
</div>
<div class="centered">
<div>
<img src="http://placehold.it/300x100" alt="" />
</div>
</div>
<div class="centered">
<div>
<img src="http://placehold.it/50x100" alt="" />
<img src="http://placehold.it/50x100" alt="" />
<img src="http://placehold.it/50x100" alt="" />
<img src="http://placehold.it/50x100" alt="" />
<img src="http://placehold.it/50x100" alt="" />
</div>
</div>
</div>

Trouble with CSS Grid Layout/Image positioning

Having some trouble trying to put together a page where images are placed properly. Screen shot attached of what I currently have in place now. What I am trying to get to would look like the first row of images (1-5) all the way down the page with every other row opposite, if that makes sense. Images 1-8 are set up correctly but 9-10 are on row 3 rather than on row 2 where I would like them. Image 11 should be left side and 12-15 should be right side. And so on..
Current css –
#grid { float: left; width: 100%; overflow: hidden; }
#grid-inner { float: left; width: 890px; overflow: hidden; }
.item { float: left; margin: 0 0 10px 0; position: relative; }
.item span { display: none; position: absolute; padding: 0 0 0 0; color: #fff; background: transparent url('../images/back-work.png') 0 0 repeat; }
.item span a { color: #fff; display: block; height: 100%; width: 100%; }
.small { width: 210px; height: 125px; }
.large { width: 420px; height: 260px; }
.small span { width: 210px; height: 125px; padding: 0 0 0 0; }
.large span { width: 420px; height: 260px; padding: 0 0 0 0; }
#project { float: left; width: 100%; }
#project-content { float: left; width: 100%; border-top: 1px solid #ccc; margin: 0 0 0 0; padding: 0 0 0 0; }
#project-content-alpha { float: left; width: 200px; }
#project-content-beta { float: left; width: 410px; }
#project-content-gamma { float: right; width: 200px; text-align: right; }
#project-content-alpha span.light { color: #999; }
#project-images { float: left; width: 100%; }
#project-images img { float: left; width: 100%; margin: 0 0 0 0; }
#project-pagination { float: left; width: 100%; margin: 0 0 0 0; }
#project-pagination-alpha { float: left; width: 200px; }
#project-pagination-beta { float: right; width: 200px; text-align: right; }
Current markup –
<div id="grid">
<div id="grid-inner">
<div class="item large">
<span>ONE</span>
<img src="" width="420" height="260" alt="ONE" />
</div>
<div class="item small">
<span>TWO</span>
<img src="" width="210" height="125" alt="TWO" />
</div>
<div class="item small">
<span>THREE</span>
<img src="" width="210" height="125" alt="THREE" />
</div>
<div class="item small">
<span>FOUR</span>
<img src="" width="210" height="125" alt="FOUR" />
</div>
<div class="item small">
<span></span>
<img src="" width="210" height="125" alt="FIVE" />
</div>
<div class="item small">
<span></span>
<img src="" width="210" height="125" alt="SIX" />
</div>
<div class="item small">
<span></span>
<img src="" width="210" height="125" alt="SEVEN" />
</div>
<div class="item large">
<span></span>
<img src="" width="420" height="260" alt="EIGHT" />
</div>
Any help or suggestions on this would be appreciated.
Thanks in advance!
CSS floats don't reposition the elements vertically. They only float horizontally.
If you want vertical "floats" (i.e. tiling), you will need to use JavaScript. I recommend the jQuery Masonry Plugin or Vanilla Masonry (jQuery Masonry minus the jQuery).
Check out the interface here. Let me know if you need revisions.
EXACTLY WHAT WAS ASKED FOR - http://jsfiddle.net/rxLTG/
HTML
<div class="wrap">
<div class="row">
<img class="lg" src="" alt="1" />
<img class="sm" src="" alt="2" />
<img class="sm" src="" alt="3" />
<img class="sm" src="" alt="4" />
<img class="sm" src="" alt="5" />
</div>
<div class="row">
<img class="sm" src="" alt="6" />
<img class="sm" src="" alt="7" />
<img class="lg" src="" alt="8" />
<img class="sm" src="" alt="9" />
<img class="sm" src="" alt="10" />
</div>
</div>
CSS
.wrap {width:650px;}
.wrap img {float:left; width:150px; height:100px;}
.wrap img.lg {width:350px; height:200px;}
.row.odd .lg, .row:nth-child(even) .lg {float:right;}​
JS
$(function () {
$('.row:odd').addClass('odd');​
});
A better way would be like this - http://jsfiddle.net/rxLTG/2/
HTML
<div class="wrap">
<img class="lg" src="" alt="1" />
<img class="sm" src="" alt="2" />
<img class="sm" src="" alt="3" />
<img class="sm" src="" alt="4" />
<img class="sm" src="" alt="5" />
<img class="lg2" src="" alt="6" />
<img class="sm" src="" alt="7" />
<img class="sm" src="" alt="8" />
<img class="sm" src="" alt="9" />
<img class="sm" src="" alt="10" />
<img class="lg" src="" alt="11" />
<img class="sm" src="" alt="12" />
<img class="sm" src="" alt="13" />
<img class="sm" src="" alt="14" />
<img class="sm" src="" alt="15" />
<img class="lg2" src="" alt="16" />
<img class="sm" src="" alt="17" />
<img class="sm" src="" alt="18" />
<img class="sm" src="" alt="19" />
<img class="sm" src="" alt="20" />
</div>
CSS
.wrap {width:500px;}
.wrap img {float:left; width:125px; height:100px;}
.wrap img.lg {width:250px; height:200px;}
.wrap img.lg2 {width:250px; height:200px;float:right;}​
Theres no need to define each row inside a div, because they will automatically fit and wrap round.
Also, if you float the large image on each row first (left or right), then the other four will fit into place without any javascript needed.
Every fifth number will then be a large image, (1,6,11,16,21 etc). If you want it to work javascript free, then use this solution. If you want to keep your original numbering system, then use the solution above.
You can just look at it as a grid. More markup, but reusable and responsive too.
For the example, you can handle this grid layout with a single class that takes the half of it's container.
first row :
- 1 column of 1/2 : has 1 large image
- 1 column of 1/2 : has 4 columns (1/2 each, and each containing a small image)
Second row : just reverse the first 1/2 columns
Columns are floated, so the col 4 and 5 will stack under 1 and 2... Your images, have to be at the right aspect ratio too.
And finally, since you're floating elements, clearfix the group.
Hope it helps.
/* Micro clearfix for the wrapper */
.wrap:before,
.wrap:after {
content: '';
display: table
}
.wrap:after {
clear: both;
}
.wrap { width:650px; }
/* no need for size if you put the right images */
img {
width:100%;
height: auto;
vertical-align: middle; /* removes the gap beneth the image */
}
/* you can go further and create some other columns */
.col-1-2 {
float: left;
width: 50%;
}
/* demo purpose only */
img {
width: 100%;
height: 100px;
}
img.lg { height: 200px; }
<div class="wrap">
<!-- one half of the wrapper -->
<div class="col-1-2">
<img class="lg" src="" alt="1" />
</div>
<!-- one half of the wrapper -->
<div class="col-1-2">
<!-- one half of the columns :: 1/4 -->
<div class="col-1-2">
<img class="" src="" alt="2" />
</div>
<div class="col-1-2">
<img class="" src="" alt="3" />
</div>
<div class="col-1-2">
<img class="" src="" alt="4" />
</div>
<div class="col-1-2">
<img class="" src="" alt="5" />
</div>
</div>
<!-- then reverse -->
<div class="col-1-2">
<div class="col-1-2">
<img class="" src="" alt="6" />
</div>
<div class="col-1-2">
<img class="" src="" alt="7" />
</div>
<div class="col-1-2">
<img class="" src="" alt="8" />
</div>
<div class="col-1-2">
<img class="" src="" alt="9" />
</div>
</div>
<div class="col-1-2">
<img class="lg" src="" alt="10" />
</div>
</div>