How do I fit the whole image with borders as there is some space below it. AnyHelp would be appreciated, thanks . I have attached my code below, please refer it .
.Details {
margin-top: 100px;
}
.flexitems {
display: flex;
margin: 10px 100px 30px 100px;
width: 70%;
margin-left: 210px;
}
.sectionimg {
/*Flex-grow flex-shrink flex-basis*/
flex: 1 1 50%;
margin-right: 20px;
border: 4px solid rgb(0, 0, 0);
border-radius: 10px;
}
.flexinvert {
flex-direction: row-reverse;
}
.sectionimg img {
max-width: 100%;
}
.sectionhead {
font-size: 30px;
}
<section class="Details">
<div class="flexitems">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="Jeans.jpg" alt="">
</div>
</div>
<div class="flexitems flexinvert">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="mainpic.png" alt="">
</div>
</div>
<div class="flexitems">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="shirt.jpg" alt="">
</div>
</div>
</section>
You can try to object fit image and fullwidth its' height.
.sectionimg img {
max-width: 100%;
object-fit: cover;
height: 100%
}
All you need to do is specify height: 100%; to .sectionimg img so the image takes the full width and height of the parent.
.Details {
margin-top: 100px;
}
.flexitems {
display: flex;
margin: 10px 100px 30px 100px;
width: 70%;
margin-left: 210px;
}
.sectionimg {
/*Flex-grow flex-shrink flex-basis*/
flex: 1 1 50%;
margin-right: 20px;
border: 4px solid rgb(0, 0, 0);
border-radius: 10px;
}
.flexinvert {
flex-direction: row-reverse;
}
.sectionimg img {
max-width: 100%;
height: 100%;
}
.sectionhead {
font-size: 30px;
}
<section class="Details">
<div class="flexitems">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="https://dummyimage.com/600x400/000/fff" alt="">
</div>
</div>
<div class="flexitems flexinvert">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="https://dummyimage.com/600x400/000/fff" alt="">
</div>
</div>
<div class="flexitems">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="https://dummyimage.com/600x400/000/fff" alt="">
</div>
</div>
</section>
Related
I want to make the image almost half the height it is now but it should cover the whole image not the zoomed part only. How do i do it?
HTML code
<section class="Details">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="Jeans.jpg" alt="">
</div>
</section>
CSS
.Details {
display: flex;
}
.sectionimg {
width: 50%;
height: 10%;
}
See the modified example below. I'd suggest you do a research about how flex layout works and how image properties work in them.
.Details {
display: flex;
}
.sectionimg {
flex: 1 0 50%;
}
.sectionimg img {
max-width: 100%;
}
<section class="Details">
<div class="sectiontext">
<p class="sectionhead">More Than 1 Lakh Collection Of Items</p>
<p class="sectionsubhead">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque ratione nostrum rem in, illo repellat eius minima aspernatur beatae ipsa officiis, fugiat enim cumque magnam. Repellendus dicta amet distinctio aspernatur!</p>
</div>
<div class="sectionimg">
<img src="https://i.stack.imgur.com/Hc97v.png" alt="">
</div>
</section>
two h4, img and p tags are grouped in separate < div>s and I've used float for img, used to separate from each other but still they overlap.
https://i.stack.imgur.com/SUxli.png
this is the image with the output.
I'm new to this, can anybody please help. Thank you.
img {
width: 50%;
height: auto;
margin: 20px 10px 20px 0px;
/* float: left; */
}
.service {
margin: 20px auto 20px auto;
text-align: left;
line-height: 2;
}
<div class="service">
<h4>Lorem ipsum dolor sit amet</h4>
<img src="image.jfif" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus ab nulla dolorum autem nisi officiis blanditiis voluptatem hic, assumenda aspernatur facere ipsam nemo ratione cumque magnam enim fugiat reprehenderit expedita.</p>
</div>
<br>
<div class="service">
<h4>Lorem ipsum dolor sit amet</h4>
<img src="image.jfif" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus ab nulla dolorum autem nisi officiis blanditiis voluptatem hic, assumenda aspernatur facere ipsam nemo ratione cumque magnam enim fugiat reprehenderit expedita.</p>
</div>
I would try nesting your code in a container that is flexed with a column flex-direction. Then I would put your <h4>'s before the service div and flex that div also, but use a flex-direction: row; See the CSS changes I made.
.container {
display: flex;
flex-direction: column;
}
p {
padding: 10px;
width: 500px;
margin: auto;
}
img {
width: 50%;
height: auto;
/* float: left; */
}
.service {
text-align: left;
line-height: 2;
display: flex;
flex-direction: row;
}
<div class="container">
<h4>Lorem ipsum dolor sit amet</h4>
<div class="service">
<img src="https://dummyimage.com/600x300/000/fff" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus ab nulla dolorum autem nisi officiis blanditiis voluptatem hic, assumenda aspernatur facere ipsam nemo ratione cumque magnam enim fugiat reprehenderit expedita.</p>
</div>
<br>
<h4>Lorem ipsum dolor sit amet</h4>
<div class="service">
<img src="https://dummyimage.com/600x300/000/fff" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus ab nulla dolorum autem nisi officiis blanditiis voluptatem hic, assumenda aspernatur facere ipsam nemo ratione cumque magnam enim fugiat reprehenderit expedita.</p>
</div>
</div>
I am having a problem. Everything seemed perfect when I finished section-3, but when I started coding section-4, it started stacking on section-3's content.
Code
HTML
<!-- Start Of SECTİON TREE !-->
<section class="section-3" id="sec3">
<div class="tribg">
<img src="Parts/triangles.png" alt="" class="img-fluid">
</div>
<div class="container-fluid">
<div class="row">
<div class="card-deck">
<div class="col-md-4">
<div class="card mycards">
<img src="Parts/shield.png" alt="" class="img-fluid" width="50px">
<div class="card-body">
<h3 class="card-title">DENEME</h3>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam sint expedita alias, dolorem sapiente culpa distinctio libero saepe. Recusandae numquam aut aliquam, ullam voluptatum placeat quis omnis perspiciatis, distinctio quae eaque nemo consequatur ratione mollitia beatae alias molestiae quod optio ipsa. Totam assumenda, aperiam quae!</p>
<div class="btn btn-primary">DENEME</div>
</div>
</div>
<div class="col-md-4">
<div class="card mycards">
<img src="Parts/shield.png" alt="" class="img-fluid" width="50px">
<div class="card-body">
<h3 class="card-title">DENEME</h3>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam sint expedita alias, dolorem sapiente culpa distinctio libero saepe. Recusandae numquam aut aliquam, ullam voluptatum placeat quis omnis perspiciatis, distinctio quae eaque nemo consequatur ratione mollitia beatae alias molestiae quod optio ipsa. Totam assumenda, aperiam quae!</p>
<div class="btn btn-primary">DENEME</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mycards">
<img src="Parts/shield.png" alt="" class="img-fluid" width="50px">
<div class="card-body">
<h3 class="card-title">DENEME</h3>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam sint expedita alias, dolorem sapiente culpa distinctio libero saepe. Recusandae numquam aut aliquam, ullam voluptatum placeat quis omnis perspiciatis, distinctio quae eaque nemo consequatur ratione mollitia beatae alias molestiae quod optio ipsa. Totam assumenda, aperiam quae!</p>
<div class="btn btn-primary">DENEME</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- End Of SECTİON TREE !-->
<!-- Start Of SECTİON FOUR !-->
<section class="section-4">
<div class="holder"><img src="Parts/shape9.png" alt="" class="img-fluid"></div>
</section>
<!-- End Of SECTİON FOUR !-->
CSS
/* SECTİON TREE */
.section-3 {
position: relative;
height: 100vh;
}
.tribg {
position: absolute;
top: 30%;
left: 20%;
z-index: 0;
}
.mycards {
padding: 60px 100px;
margin-top: 8rem;
border-radius: 63px;
box-shadow: 6px 7px 100px rgba(0, 0, 0, 0.16);
transition: .3s;
}
.mycards p {
margin-bottom: 6rem;
}
.cardimg {
margin-bottom: 30px;
}
.mycards:hover {
transform: translateY(-30px);
}
.gotopanel {
font-size: 20px;
}
/* End Of SECTİON TREE */
/* SECTİON FOUR */
.section-4 {
height: 100vh;
}
The problem is in your css, remove or change height property here:
.section-3 {
position: relative;
height: 100vh;
}
.section-4 {
height: 100vh;
}
I have three divs in one container div. Second of them has got only text and it's height is dynamic depending of text height. First and third has got images and I want to fill out the rest of height that those 3 divs have the same height. How to set height of image to fill out the rest of remaining height??
When I set height 100% to image and parent div has got e.g. 600px , image is getting 600px too and it's overflowing content.
.offer-container {
display: flex;
justify-content: space-between;
> div {
width: 30%;
}
img {
height: 100%;
width: 100%;
object-fit: cover;
}
}
EDIT
<div className='offer-container'>
<div>
<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Ipsum hic a nulla debitis adipisci cupiditate
velit deleniti sint obcaecati? Ex quia illum id facere nulla dolores, cupiditate veniam explicabo
excepturi?
</p>
<div>
<img src='/images/bgc.png' alt='' />
</div>
</div>
<div>text...</div>
<div><img src='/images/bgc.png' alt='' /></div>
</div>
Hey this would solve your problem:
.parent{
display: flex;
}
.child {
width: 350px;
}
.class-1 {
display: flex;
flex-direction: column;
}
#image{
width: 90%;
height:100%;
overflow: hidden;
flex-grow : 1;
position: relative;
}
#image img {
width: 100%;
height: auto;
position:absolute;
}
<div class="parent">
<div class=" child class-1">
<div class="text">
<p>asdsadasdsadasdasdasdasdaj sjflskdjfkasj flksadj flksadj flksadj flkasdj flkasdjfklasdj flkasdjflkas jflksadj lkasjfklasdj f</p>
</div>
<div id="image">
<!-- <div class="for-image" style = "background-image:url('https://rsvpify.com/wp-content/uploads/2017/02/wedding-day-couple-chicago.jpg')"> -->
<img src="https://rsvpify.com/wp-content/uploads/2017/02/wedding-day-couple-chicago.jpg" alt="">
</div>
</div>
<div class=" child 2">
<p>asdsadasdsadasdasdasdasdaj sjflskdjfkasj flksadj lkasjfklasdj fasdsadasdsadasdasdasdasdaj sjflskdjfkasj flksadj flksadj flksadj flkasdj flkasdjfklasdj flkasdjflkas jflksadj ldj flksadj flksadj flkasdj flkasdjfklasdj flkasdsadsads a das d aasdsadsaddasd as asd asd s ds das das das d ads asd asasdjflkas jflgsdvxzvxzcvzxcvzxv</p>
</div>
</div>
if you want to fiddle around here is the codepen link
Flex-grow fixed this problem
.parent{
display: flex;
justify-content: space-between;
}
.parent > div {
width: 48%;
}
.parent > div:first-child {
display: flex;
flex-direction: column
}
.image{
flex-grow: 1;
}
.image img {
width: 100%;
height: 100%;
object-fit: cover;
}
<div class="parent">
<div>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Aliquam accusamus necessitatibus unde ex modi
mollitia in est doloremque impedit, eligendi odit beatae quasi pariatur! Tempora doloribus maxime
inventore ipsum. Voluptates.</p>
<div class="image">
<img src="https://rsvpify.com/wp-content/uploads/2017/02/wedding-day-couple-chicago.jpg" alt="">
</div>
</div>
<div>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Aliquam accusamus necessitatibus unde ex modi
mollitia in est doloremque impedit, eligendi odit beatae quasi pariatur! Tempora doloribus maxime
inventore ipsum. Voluptates.
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Aliquam accusamus necessitatibus unde ex modi
mollitia in est doloremque impedit, eligendi odit beatae quasi pariatur! Tempora doloribus maxime
inventore ipsum. Voluptates.</p>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Aliquam accusamus necessitatibus unde ex modi
mollitia in est doloremque impedit, eligendi odit beatae quasi pariatur! Tempora doloribus maxime
inventore ipsum. Voluptates.
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Aliquam accusamus necessitatibus unde ex modi
mollitia in est doloremque impedit, eligendi odit beatae quasi pariatur! Tempora doloribus maxime
inventore ipsum. Voluptates.</p>
</div>
</div>
So I tried to play a bit with my code and was looking on many forums to see if the answer was already given. I didn't find anything yet. I wanted to know how to align the buttons divs to each other, like this :
At this time, my code is this :
.directeur {
width: 50%;
float: left;
}
.directeur p {
width: 80%;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
margin-top: 10px;
}
.directeur a>img {
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
display: block;
}
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur maxime impedit amet labore facere. Quod quos consectetur nulla eaque soluta tenetur omnis quo sunt, modi optio iste consequuntur atque error.</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus rem delectus enim dolorem, error nulla earum maxime aliquid ipsam, recusandae molestiae ducimus iusto, dolore omnis. Saepe temporibus autem, provident dolor!</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
Can someone help me ? I created other Divs, tried Vertical-Align and Inline-Block. I want the Green Button Rectangle to align like this in my code. At the moment, they are not align because of the height of the text box.
Have you tried this.
.custom_element{
position: absolute;
left:0;
right:0;
text-align: center;
}
Replace custom_element with your required element.
This is a job for Flexbox!
Wrap you whold code in a flexbox container, which will ensure all your .directeurs have the same height
Use flexbox for your .directeur, with flex-direction: column to arrange sub-elements vertically.
Set margin-top: auto on your last element (.directeur a) to ensure it will always be a the very bottom of its parent.
.directeurs {
display: flex;
}
.directeur{
width: 50%;
display: flex;
flex-direction: column;
align-items: center;
}
.directeur p {
width: 80%;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
margin-top: 10px;
}
.directeur a {
margin-top: auto;
}
.directeur a > img{
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
display: block;
}
<div class="directeurs">
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur maxime impedit amet labore facere. Quod quos consectetur nulla eaque soluta tenetur omnis quo sunt, modi optio iste consequuntur atque error.</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus rem delectus enim dolorem, error nulla earum maxime aliquid ipsam, recusandae molestiae ducimus iusto, dolore omnis. Saepe temporibus autem, provident dolor! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus rem delectus enim dolorem, error nulla earum maxime aliquid ipsam, recusandae molestiae ducimus iusto, dolore omnis. Saepe temporibus autem, provident dolor!</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
</div>
Set a min-height for the Lorem ipsum parts of this to make them the same:
.directeur{
width: 50%;
float: left;
}
.directeur p {
width: 80%;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
margin-top: 10px;
min-height: 225px;
}
.directeur a>img{
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
display: block;
}
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur maxime impedit amet labore facere. Quod quos consectetur nulla eaque soluta tenetur omnis quo sunt, modi optio iste consequuntur atque error.</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus rem delectus enim dolorem, error nulla earum maxime aliquid ipsam, recusandae molestiae ducimus iusto, dolore omnis. Saepe temporibus autem, provident dolor!</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
Or you can use some javascript to measure the tallest one then make the other one the same height on page load, something like Equalise.
You can use display:table-cell and position. I have taken the liberty of adding a wrapper around the two .directeurs. See it it works for you.
.directeur-wrapper{
display:table;
}
.directeur{
display:table-cell;
width:50%;
padding:20px 20px 80px;
position:relative;
}
.directeur img{max-width:100%;}
.directeur a{position:absolute; bottom:0;}
<div class="directeur-wrapper">
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur maxime impedit amet labore facere. Quod quos consectetur nulla eaque soluta tenetur omnis quo sunt, modi optio iste consequuntur atque error.</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
<div class="directeur">
<img src="http://via.placeholder.com/500x150" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus rem delectus enim dolorem, error nulla earum maxime aliquid ipsam, recusandae molestiae ducimus iusto, dolore omnis. Saepe temporibus autem, provident dolor!</p>
<img src="http://via.placeholder.com/300x70" alt="">
</div>
</div>