CSS images not aligning correctly - html

I'm having a problem with my CSS, I assume. I want the picture of the lipstick to align with the face image and have the nail one underneath both of them.
HTML
<center>
<div id="homepage-image preventOverflow homepageHero {{ section.settings.height }} {{ section.settings.color }} index-section">
<div id="left">
<img width=600px type="image/jpeg" src="{{ 'lipstickpink.jpg' | asset_url}}" />
<!-- <img width=600px type="image/jpeg" src="{{ 'shadow.jpg' | asset_url}}" /> -->
</div>
<div id="right">
<div id="top-right">
<img width=900px type="image/png" src="{{ 'faceglam.png' | asset_url}}" />
</div>
<div id="bottom-right">
<img width=600px type="image/jpeg" src="{{ '11_Vertigo_1024x1024.jpg' | asset_url}}" />
</div>
</div>
</div> </center>
CSS
#container {
height: 100%;
width: 100%;
padding-top: $gutter*3;
padding-bottom: $gutter*2;
}
#left > img:nth-of-type(1) {
height: 85vh;
width: 70vw;
}
#left > img:nth-of-type(2) {
height: 65vh;
width: 49vw;
}
#left, #right {
display: inline-block;
}
#top-right, #bottom-right {
display: block;
}
#top-right > img:nth-of-type(1) {
width: 100vw;
height: 100vh;
}
#top-right > img:nth-of-type(2) {
width: 35vw;
height: 60vh;
}
#bottom-right > img:nth-of-type(1) {
width: 60vw;
height: 60vh;
}
#bottom-right > img:nth-of-type(2) {
width: 20vw;
height: 25vh;
}
I have also provided an image of the problem:

It's not completely clear how (i.e in which direction) you want them aligned.
You have a lot of seemingly unnecessary divs - i wondered why.. so I have adjusted both HTML and CSS (used own images from internet)
If I got them in the wrong order, just adjust the images. I adjusted heights (re-adjustable obviously)- but hope you get the general gist!
Hope this helps
#container {
height: 100%;
width: 100%;
margin: 0;
padding-top: $gutter*3;
padding-bottom: $gutter*2;
}
#left{
margin-left:10%;
margin-right:10%;
}
#left > img:nth-of-type(1) {
max-height:200px;
padding:5px;
height:auto;
}
#left > img:nth-of-type(2) {
max-height:300px;
padding:5px;
height: 60vh;
}
#left,
#right {
display: inline-block;
}
#right > img:nth-of-type(1) {
max-height:300px;
height: auto;
margin-left:18vw;
margin-right:18vw;
}
<div id="container">
<div id="left">
<img src="https://lh3.googleusercontent.com/czZtMqTum5GQOYL1NxogiEVZ57Zr5LG0chnil-p3YFTjl3WIQdrADqpaaATmyN-JGjey=h900" alt="face" />
<img src="http://bpc.h-cdn.co/assets/16/38/480x480/gallery-1474299136-urban-decay-vice-pink-lipstick.jpg" alt="lipstick" />
</div>
<div id="right">
<img src="http://www.vipera.com.pl/wp-content/uploads/2016/08/20zestawy_lakier__w_do_artystycznego_zdobienia_paznokci________artistic_manicure_set___219.jpg" alt="nails" />
</div>
</div>
Fiddle

Related

How can i put this 4 images inside of 1 image?

I am stuck at the moment to put this 4 images (in the same row) inside of the div with image.
Html:
.iniciRo img {
width: 100%;
}
.iniciRo .coluna img {
width: 270px;
z-index: 4;
}
.iniciRo>div {
padding: 30px 0 10px 0;
}
.iniciRo .row>div {
padding-bottom: 20px;
}
.coluna {
position: relative;
padding-left: 15px;
padding-right: 15px;
float: left;
}
.row {
width: 100%;
margin-left: auto;
margin-right: auto;
margin-top: 0;
margin-bottom: 0;
max-width: 75em;
}
<div class="iniciRo">
<img src="assets/images/Rodape/backbot.png">
<div>
<div class="row">
<div class="coluna">
<img src="assets/images/Rodape/visitas-escolas.png" />
</div>
<div class="coluna">
<img src="assets/images/Rodape/rafc.png" />
</div>
<div class="coluna">
<img src="assets/images/Rodape/rioavetv.png" />
</div>
<div class="coluna">
<img src="assets/images/Rodape/galeri.png" />
</div>
</div>
</div>
</div>
I already tried to use z-index but nothing happened.
Any help is going to be appreciated, please help me...
Like this:
coluna img {
position: relative;
padding: 50em;
}
.iniciRo img{
position: absolute;
width: 100%;
}
.iniciRo > div{
padding: 30px 0 10px 0;
}
.iniciRo .row > div{
padding-bottom: 20px;
}
.coluna{
position: relative;
padding-left: 15px;
padding-right: 15px;
margin-bottom: 30em;
}
.row{
position: relative;
display: flex;
flex-direction: column;
width: 100%;
max-width: 75em;
clear: both;
}
In other words you want position: absolute for the iniciRo img, position: relative for .row, and the use of flexbox for .row. Here's a JS Fiddle.
Use this Flexbox css code
<div class="flex-container">
<div>
<img src="https://placehold.it/350x150" />
</div>
<div>
<img src="https://placehold.it/350x150" />
</div>
<div>
<img src="https://placehold.it/350x150" />
</div>
<div>
<img src="https://placehold.it/350x150" />
</div>
</div>
.flex-container{
display:flex;
}
.flex-container div {
flex:1;
margin:5px;
}
img {
width:100%;
}

Scaling two different imgsto fit the screen

I'm trying to scale two images to fit a mobile screen with both keeping their original proportions without overflow. When I've tried to apply max-width it only kicks in when one image falls below screen width.
.one img {
position: absolute;
width: 200px;
height: 200px;
}
.two img {
position: absolute;
margin-left: 200px;
width: 300px;
height: 200px;
}
<div class="one"><img src="https://upload.wikimedia.org/wikipedia/commons/5/57/Distribution_H._leucocephalus.png"></div>
<div class="two"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg/800px-Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg"></div>
Try:
* {
margin: 0;
padding: 0;
}
.slider {
display: flex;
}
.slider .slide img {
width: 100%;
}
<div class="slider">
<div class="slide">
<img src="https://upload.wikimedia.org/wikipedia/commons/5/57/Distribution_H._leucocephalus.png" style="max-width: 200px;">
</div>
<div class="slide">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg/800px-Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg"
style="max-width: 300px;">
</div>
</div>
Check this:
.container {
display: flex;
}
.one img {
width: 100%;
max-width: 200px;
}
.two img {
width: 100%;
max-width: 300px;
}
<div class="container">
<div class="one"><img src="https://upload.wikimedia.org/wikipedia/commons/5/57/Distribution_H._leucocephalus.png"></div>
<div class="two"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg/800px-Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg"></div>
</div>
.one, .two {
width:50%; float:left
}
.one img, .two img {
width: 100%;
}
<div class="one"><img src="https://upload.wikimedia.org/wikipedia/commons/5/57/Distribution_H._leucocephalus.png"></div>
<div class="two"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg/800px-Back_to_the_Six_Mile_Lake_eagles_%28Haliaeetus_leucocephalus%29.%22feed_me_mom%22._%2819159890706%29.jpg"></div>
Can you please check this and let me know, if this is the same you are looking for.

Get rid of extra space in image gallery

I'm trying to figure out why there is extra space added to the right of the thumbnail images. I put a red border around the area to make it easier to see the extra white space. how would I remove it?
Any advice would be greatly appreciated.
jQuery(document).ready(function() {
$('.thumb').click(function() {
$('.main-image img').attr('src', $(this).children('img').attr('src'));
});
});
.pics {
overflow: hidden;
width: 60%;
box-sizing: border-box;
padding-left: 6em;
display:flex;
justify-content:center;
}
.main-image {
width: 100%;
}
.main-image img {
width: 100%
}
.thumb {
position:relative;
width:30%;
height:auto;
margin:1em;
border: 1px solid blue;
}
.selection-image {
display:flex;
flex-direction:column;
border:1px solid red;
}
.selection-image img {
width:100%;
height: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pics">
<div class="main-image">
<img src="https://images.unsplash.com/photo-1502901047037-d0184a3efead?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=e5e38bba3f79d4f86a648d7e9961ca09">
</div>
<div class="selection-image">
<div class="thumb">
<img src="https://images.unsplash.com/photo-1502901047037-d0184a3efead?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=e5e38bba3f79d4f86a648d7e9961ca09">
</div>
<div class="thumb">
<img src="https://images.unsplash.com/photo-1511644547841-f467df8071a4?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=151cc232aa6e73bab1aa03d23b276046">
</div>
<div class="thumb">
<img src="https://images.unsplash.com/photo-1477868433719-7c5f2731b310?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=5d54dfa7ff8cdf7d4214d468d7c7443b">
</div>
</div>
</div>
You are setting width of the pictures in thumb class to 30% and not centering the images. Set width of thumb class to auto and you can remove margin/padding if you want no white space.
.thumb {
position:relative;
width:auto;
height:auto;
margin:1em;
border: 1px solid blue;
}
Maybe simply move the width:30% to the container instead. Also make the image block to avoid the whitespace under them:
jQuery(document).ready(function() {
$('.thumb').click(function() {
$('.main-image img').attr('src', $(this).children('img').attr('src'));
});
});
.pics {
overflow: hidden;
width: 60%;
box-sizing: border-box;
padding-left: 6em;
display: flex;
justify-content: center;
}
.main-image {
width: 100%;
}
.main-image img {
width: 100%;
}
.thumb {
position: relative;
height: auto;
margin: 1em;
border: 1px solid blue;
}
.thumb img {
display: block;
}
.selection-image {
display: flex;
width: 30%;
flex-direction: column;
border: 1px solid red;
}
.selection-image img {
width: 100%;
height: auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pics">
<div class="main-image">
<img src="https://images.unsplash.com/photo-1502901047037-d0184a3efead?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=e5e38bba3f79d4f86a648d7e9961ca09">
</div>
<div class="selection-image">
<div class="thumb">
<img src="https://images.unsplash.com/photo-1502901047037-d0184a3efead?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=e5e38bba3f79d4f86a648d7e9961ca09">
</div>
<div class="thumb">
<img src="https://images.unsplash.com/photo-1511644547841-f467df8071a4?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=151cc232aa6e73bab1aa03d23b276046">
</div>
<div class="thumb">
<img src="https://images.unsplash.com/photo-1477868433719-7c5f2731b310?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=5d54dfa7ff8cdf7d4214d468d7c7443b">
</div>
</div>
</div>

adding Masonry style images to section of a website

Ive been trying to add a masonry section of images to my website. However it is not aligning correctly. It just stacks the pictures onto of each other. How could I go about creating a masonry section using css/html? Or maybe creating a table that gives the masonry effect?
MY HTML:
<div class="masonry">
<div class="item">IMAGE GOES HERE</div>
<div class="item">SECOND IMAGE </div>
THIRD IMAGE
<div class="item">FOURTH IMAGE</div>
</div>
MY CSS:
.masonry { /* Masonry container */
column-count: 4;
column-gap: 1em;
}
.item { /* Masonry bricks or child elements */
background-color: #eee;
display: inline-block;
margin: 0 0 1em;
width: 100%;
}
The picture below is what I am trying to achieve:
Here you go:
#container {
height: 100%;
width: 100%;
}
#left > img:nth-of-type(1) {
height: 25vh;
width: 35vw;
}
#left > img:nth-of-type(2) {
height: 60vh;
width: 35vw;
}
#left, #right {
display: inline-block;
}
#top-right, #bottom-right {
display: block;
}
#top-right > img:nth-of-type(1) {
width: 25vw;
height: 60vh;
}
#top-right > img:nth-of-type(2) {
width: 35vw;
height: 60vh;
}
#bottom-right > img:nth-of-type(1) {
width: 40vw;
height: 25vh;
}
#bottom-right > img:nth-of-type(2) {
width: 20vw;
height: 25vh;
}
<div id="container">
<div id="left">
<img src="Image 1">
<br>
<img src="Image 2">
</div>
<div id="right">
<div id="top-right">
<img src="Image 3">
<img src="Image 4">
</div>
<div id="bottom-right">
<img src="Image 5">
<img src="Image 6">
</div>
</div>
</div>

Div with text in middle and right

I want to have a div with two images on the left, some centered text and some text on the right.
One of the many attempts:
http://jsfiddle.net/yu8bz4h4/
The problem is that I cant figure out how to get the p elements in the same line while keeping center and right the alignments
HTML:
<div class="outer">
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
<p class="center" >centered</p>
<p class="right" >right</p>
</div>
CSS:
.outer {
height: 50px;
width: 800px;
}
.icon {
width: 44px;
height: 44px;
}
.outer p {
margin 0;
}
.center {
text-align: center;
width: auto;
}
.right {
text-align: right;
width: auto;
}
Replace all p with div.Then write css code.The text comes in one line.
Hope this works.
.outer {
height: 50px;
width: 800px;
}
.icon {
width: 44px;
height: 44px;
}
.outer p {
margin 0;
}
.center {
margin-left:50%;
width: auto;
position:absolute
}
.right {
margin-left:100%;
width: auto;
position: absolute;
}
<div class="outer">
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
<div class="center" >centered</div>
<div class="right" >right</div>
</div>
I am pretty much sure you wanted something like this. Though your question is not clear. Never forget to write codes with semantic meaning. Here's your solution following more semantic way: codepen.
Or here:
.outer {
height: 50px;
width: 800px;
overflow: hidden;
}
.column {
width: 33.33%;
float: left;
}
.icon {
width: 44px;
height: 44px;
margin-right: 10px;
}
.center {
text-align: center;
}
.right {
text-align: right;
}
<div class="outer">
<div class="column">
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
</div>
<div class="column">
<p class="center">centered</p>
</div>
<div class="column">
<p class="right">right</p>
</div>
</div>
Revised code in response to OP's comments:
.outer {
height: 50px;
width: 300px;
position: relative;
}
.icon {
width: 44px;
height: 44px;
float: left;
}
.center {
text-align: center;
width: 100%;
position: absolute;
left: 0;
}
.right {
position: absolute;
right: 0;
width: auto;
}
<div class="outer">
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
<img class="icon" src="http://www.mobafire.com/images/champion/icon/leona.png" />
<p class="center">centered</p>
<p class="right">right</p>
</div>