I'm trying to position my div .valorCard on top of my image. I want the div to have a piece of it on top of the end of the image, I'm using relative position on the image and absolute position on the div and a value on the bottom for that. But the div is covering my second section and I don't want that to happen. Can someone help me? I can't use absolute position in my second section because it ruins the style of it.
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.valorCard {
padding: 0 24px;
position: absolute;
bottom: -190px;
width: 150px;
}
.valorCard-content {
border: 2px solid green;
background-color: grey;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
As I unserstand your explanation I thing this is the behavior that you desire.
Most in common. You already have used the flexbox with a column whih is nice.
If you would like to rearragne the elements inside the flex container there is no need to use the position: absolute. You have to just use the order: NUMBER property to order the elements inside the flex.
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.valorCard {
padding: 0 24px;
bottom: -190px;
width: 60%;
order: 0;
}
.valorImagem {
order: 1;
}
.valorCard-content {
border: 2px solid green;
background-color: grey;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
If I understand your intentions correctly, you can add overflow: hidden; to the css for #valorContent to hide the overflowing part:
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
}
.valorCard {
padding: 0 24px;
position: absolute;
bottom: -190px;
width: 150px;
}
.valorCard-content {
border: 2px solid green;
background-color: grey;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
Related
I want my div .valorCard-content to take up space and stop sitting on top of the second section. I want it to continue with a portion on top of the image as an overlay, but I don't want it to cover the second section. How do I take up space and the second section is positioned at the bottom, not being covered by the div .valorCard-content?
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.valorCard {
padding: 0 24px;
position: absolute;
top: 370px;
}
.valorCard-content {
border: 2px solid green;
background-color: white;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
It's generally best to avoid absolute dimensional values in CSS. Instead, use percentages or other relative values. Here you could also do something like calc(100% + 10px) to give a specific top margin.
A better solution might be to nest the elements according to their visual location. If you want an element to overlay another, it should really be that element's child. Of course, you may want a document structure as you have it now for proper text flow.
Protip: Use border rather than rules for visual lines. It keeps your markup cleaner and gives more flexibility. If you're using Bootstrap, use the classes provided.
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.valorCard {
padding: 0 24px;
position: absolute;
top: 100%;
/* <--------------------------- HERE */
}
.valorCard-content {
border: 2px solid green;
background-color: white;
}
.border-bottom {
border-bottom: 1px solid #ddd;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://via.placeholder.com/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4 mb-2 border-bottom">
Lorem Ipsum
</h2>
<div class="valor-lista">
<div class="item border-bottom">
<h4 class="mx-4">Test</h4>
</div>
<div class="item border-bottom">
<h4 class="mx-4">Test</h4>
</div>
<div class="item border-bottom">
<h4 class="mx-4">Test</h4>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
Update as the original answer did not address the issue anymore after OP redacted the question.
To solve the issue now:
reenable .valorCard { position: absolute; top: 370px } (if you disabled it).
add #valorCard-content { margin-bottom: 250px } to move the .second section down from under #valorCard-content (or any value that fits your needs).
#valorContent {
padding: 0;
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 250px;
}
.valorCard {
padding: 0 24px;
position: absolute;
top: 370px;
}
.valorCard-content {
border: 2px solid green;
background-color: white;
}
<section class="valor py-5 mt-4">
<div class="container pt-5" id="valorContent">
<div class="valorImagem">
<img class="img-fluid" src="https://source.unsplash.com/user/c_v_r/414x421">
</div>
<div class="valorCard text-center">
<div class="valorCard-content py-5 px-4">
<h2 class="valor-titulo mx-4">
Lorem Ipsum
</h2>
<hr>
<div class="valor-lista">
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
<div class="item ">
<h4 class="mx-4">Test</h4>
</div>
<hr>
</div>
</div>
</div>
</div>
<!-- </div> -->
</section>
<section class="second">
<div>
<div>
<div>
<div>
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
<div class="col-lg-5 cardbox cardbox-dep">
<div class="p-4 pt-5 mx-2">
<p class="depoimento-txt">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
</div>
</div>
</div>
</div>
</section>
I have an element on the page which, when it is hovered over, expands and reveals some previously hidden text within it. The problem is that when the element expands, it moves other content below it. I tried to use position:absolute, but it has not achieved the desired effect.
.col {
padding: 20px;
}
.col:hover {
background-color: lightgray;
}
.revealOnHover {
display: none;
/*position: absolute;*/
}
#block1:hover .revealOnHover,
#block2:hover .revealOnHover {
display: block;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
<div class="container">
<div class="row">
<div class="col" id="block1">
<img src="https://picsum.photos/100/100?random=1">
<p><b>Lorem ipsum dolor sit amet</b></p>
<i class="fas fa-caret-down" style="color: red;"></i>
<p class="revealOnHover">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col" id="block2">
<img src="https://picsum.photos/100/100?random=1">
<p><b>Excepteur sint occaecat cupidatat non proident</b></p>
<i class="fas fa-caret-down" style="color: red;"></i>
<p class="revealOnHover">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<p> </p>
<div style="text-align: center;">
<button type="button" class="btn btn-secondary" style="font-weight: bold; margin: 0 auto; margin-right: 2rem; color: #FFF">Click here</button>
<button type="button" class="btn btn-secondary" style="font-weight: bold; margin: 0 auto; margin-right: 2rem; color: #FFF">Click here</button>
</div>
</div>
My Code: https://codepen.io/eren5897/pen/GRqgOyd
You're not far off actually. position:absolute is the way to go, but you need a few additional styles to make it work, mainly in order to correctly position it and make it share the background color of its parent.
.col {
padding: 20px;
}
.col:hover {
background-color: lightgray;
}
.revealOnHover {
display: none;
position: absolute;
left: 0;
right: 0;
padding: 10px;
background: inherit;
}
#block1:hover .revealOnHover,
#block2:hover .revealOnHover {
display: block;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
<div class="container">
<div class="row">
<div class="col" id="block1">
<img src="https://picsum.photos/100/100?random=1">
<p><b>Lorem ipsum dolor sit amet</b></p>
<i class="fas fa-caret-down" style="color: red;"></i>
<p class="revealOnHover">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="col" id="block2">
<img src="https://picsum.photos/100/100?random=1">
<p><b>Excepteur sint occaecat cupidatat non proident</b></p>
<i class="fas fa-caret-down" style="color: red;"></i>
<p class="revealOnHover">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
<p> </p>
<div style="text-align: center;">
<button type="button" class="btn btn-secondary" style="font-weight: bold; margin: 0 auto; margin-right: 2rem; color: #FFF">Click here</button>
<button type="button" class="btn btn-secondary" style="font-weight: bold; margin: 0 auto; margin-right: 2rem; color: #FFF">Click here</button>
</div>
</div>
Add min-height to your row class
Your class becomes
.row {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
min-height: 317PX;}
How about adding
.row {
min-height: 20rem
}
This makes sure that they don't move when the divs are being expanded.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am trying to build the testimonial section but it's not placing orderly, it's placing within the services section. here's the codepen link:
https://codepen.io/Razu381/pen/XQJVzg
here is the code:
<div class="section-testimonial">
<div class="row" >
<div class="col-md-2">
<h2> What people say about me</h2>
</div>
<div class="col-md-10">
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p>
</div>
</div>
</div>
just remove this css:
.section-services{
}
.services-overlay{
position: absolute;
top: 80%;
}
check out my answer:
#import url('https://fonts.googleapis.com/css?family=Josefin+Slab:300,400|Lato:300i,400|Pacifico|Tangerine:400,700&display=swap');
body{
font-family: lato;
font-size: 20px;
}
.header-text{
font-size: 30px;
font-weight: bold;
word-spacing: 3px;
letter-spacing: 3px;
font-family: Abril Fatface;
color:#2ecc71;
}
.degrees{
font-size: 20px;
}
.top-nav{
font-size: 20px;
font-family: lato;
}
.navbar-light .navbar-nav .nav-link{
color: black;
margin: 3px;
}
.s-icon i{
margin:3px;
}
/*----about me section---*/
.section-about{
background: #f8f8f8;
}
.section-about h2{
font-family: Abril Fatface;
font-size: 40px!important;
letter-spacing: 3px;
word-spacing: 4px;
}
.section-about h2{
margin-top: 100px;
}
h2:after {
display: block;
width: 100px;
height: 3px;
background-color: #2ecc71;
content: "";
margin-top: 10px;
margin-bottom: 10px;
}
.section-about p{
margin-top: 30px;
}
/*----services section---*/
.section-services .card{
background-color: #2ecc713d;
}
.section-services .card-header{
background-color:#2ecc71;
text-align: center;
margin:5px 0;
}
.section-services h2{
font-family: Abril Fatface;
font-size: 40px!important;
letter-spacing: 3px;
word-spacing: 4px;
position: absolute;
top: 10%;
right: 50%;
text-transform: uppercase;
}
.section-services h2:after{
width: 220px;
}
.section-services p{
text-align: center;
}
.section-services .card-body img{
max-width: 100%;
text-align: center;
display: block;
height: 150px;
width: 50%;
margin: 0 auto;
}
/*------section-testimonial---*/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>homw</title>
<script src="https://kit.fontawesome.com/7ea1edf4c8.js"></script>
<link href="https://fonts.googleapis.com/css?family=Josefin+Slab|Lato|Pacifico|Tangerine&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="resources/css/style.css">
<link href="https://fonts.googleapis.com/css?family=Abril+Fatface|Roboto&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/367919f9b0.js"></script>
<style>
.carousel-item{
height: 100vh;
}
.carousel-item img{
height: 100vh;
object-fit:cover;
overflow: hidden;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-light bg-light">
<a class="navbar-brand" style="font-family:Pacifico;font-size: 30px;color: #2ecc71;" href="#">DR. S. Faruqi</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<div class="navbar-nav mx-auto top-nav" >
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">About Me</a>
<a class="nav-item nav-link" href="#">Services</a>
<a class="nav-item nav-link " href="#">Testimonials</a>
<a class="nav-item nav-link " href="#">Chembers</a>
</div>
<span class="s-icon">
<i class="fab fa-facebook-square fa-2x"></i>
<i class="fab fa-twitter-square fa-2x"></i>
<i class="fab fa-youtube-square fa-2x"></i>
</span>
</div>
</nav>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel" style="height: 100vh;position: relative;">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://source.unsplash.com/random" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="https://source.unsplash.com/random/2" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="https://source.unsplash.com/random/3" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="https://source.unsplash.com/random/4" class="d-block w-100" alt="...">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div class="section-about">
<div class="container">
<div class="row">
<div class="col-md-5">
<h2>About Me</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. </p>
</div>
<div class="col-md-7">
<img src="https://source.unsplash.com/random/22" alt="" class="img-fluid">
</div>
</div>
</div>
</div>
<div class="section-services "style="position:relative ;" >
<img src="https://source.unsplash.com/random/5.png" alt="" style="width: 100%;height: 400px;">
<h2>Services </h2>
<div class="container">
<div class="services-inner">
<div class="row services-overlay ">
<div class="col-md-4 ">
<div class="card">
<div class="card-body">
<img src="https://source.unsplash.com/random/6" alt="" class=" card-img-top " >
<h4 class="card-header">Primary Treatment</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
</div>
</div>
</div>
<div class="col-md-4 ">
<div class="card">
<div class="card-body">
<img src="https://source.unsplash.com/random/7" alt="" class="card-img-top " >
<h4 class="card-header">Primary Injury</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
</div>
</div>
</div>
<div class="col-md-4 ">
<div class="card">
<div class="card-body">
<img src="https://source.unsplash.com/random/8" alt="" class=" card-img-top " >
<h4 class="card-header">Vaccination</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
</div>
</div>
</div>
<div class="col-md-4 ">
<div class="card">
<div class="card-body">
<img src="https://source.unsplash.com/random/9" alt="" class=" card-img-top " >
<h4 class="card-header">Health Advice</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
</div>
</div>
</div>
<div class="col-md-4 ">
<div class="card">
<div class="card-body">
<img src="https://source.unsplash.com/random/10" alt="" class=" card-img-top " >
<h4 class="card-header">Childern care</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
</div>
</div>
</div>
<div class="col-md-4 ">
<div class="card">
<div class="card-body">
<img src="https://source.unsplash.com/random/11" alt="" class=" card-img-top">
<h4 class="card-header">Health education</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
</div>
</div>
</div>
</div>
<!--end of row-->
</div>
</div>
</div>
<div class="section-testimonial">
<div class="row" >
<div class="col-md-2">
<h2> What people say about me</h2>
</div>
<div class="col-md-10">
<p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
</body>
</html>
I have a pretty basic structure like so
<section id="portfolio">
<div class="col-lg-5 col-sm-5 vertical-center" id="portfolio-left">
<div id="portfolio-title">
<h2>Work</h2>
</div>
</div>
<div class="col-lg-7 col-sm-7" id="portfolio-right">
<div class="swiper-slide goldBG" id="cSlide2">
<div class="col-md-6 col-md-offset-3 vertical-center" id="inner">
<h3>Some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
</section>
It has a left section and a right section. Now I wanted the content within these section to be vertically aligned in the middle, so I used flex for the first time
.vertical-center {
align-items: center;
display: flex;
}
This works well as you can see from the JSFiddle The problem I am having is with the right section. You can see that it is vertically aligned correctly, however, the items (h3 and p) inside seem to be aligned inline.
Is there any way I can get these items to display as a block? I have tried a few things that do this, but then it messes up my vertically alignment.
Any advice appreciated.
Thanks
Make you inner div a column flexbox:
#inner {
flex-direction: column;
align-items: flex-start;
justify-content: center;
}
See demo below:
#portfolio {
height: 100vh;
}
section#portfolio {
padding-bottom: 0;
padding-top: 0;
}
#portfolio-right {
height: 100%;
padding: 0;
}
#cSlide2 {
height: 350px !important;
}
#cSlide2 #inner {
height: 100%;
}
.vertical-center {
align-items: center;
display: flex;
}
#portfolio-right .goldBG {
background: #fabc2f;
}
#portfolio-left {
height: 100%;
background: #35a887;
}
#inner {
flex-direction: column;
align-items: flex-start;
justify-content: center;
}
<section id="portfolio">
<div class="col-lg-5 col-sm-5 vertical-center" id="portfolio-left">
<div id="portfolio-title">
<h2>Work</h2>
</div>
</div>
<div class="col-lg-7 col-sm-7" id="portfolio-right">
<div class="swiper-slide goldBG" id="cSlide2">
<div class="col-md-6 col-md-offset-3 vertical-center" id="inner">
<h3>Some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
</section>
Put your <h3> & <p> inside a parent <div> (in my case its .content-holder). Because its the property to flex to inline the items.
Like:
<div class="content-holder">
<h3>Some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
You can use flex-direction: column too but this will make each of your content wrap to next line, so its better to wrap these into a parent div.
Have a look at the snippet below:
#portfolio {
height:100vh;
}
section#portfolio {
padding-bottom: 0;
padding-top: 0;
}
#portfolio-right {
height: 100%;
padding: 0;
}
#cSlide2 {
height:350px !important;
}
#cSlide2 #inner {
height:100%;
}
.vertical-center {
align-items: center;
display: flex;
}
#portfolio-right .goldBG {
background: #fabc2f;
}
#portfolio-left {
height:100%;
background: #35a887;
}
<section id="portfolio">
<div class="col-lg-5 col-sm-5 vertical-center" id="portfolio-left">
<div id="portfolio-title">
<h2>Work</h2>
</div>
</div>
<div class="col-lg-7 col-sm-7" id="portfolio-right">
<div class="swiper-slide goldBG" id="cSlide2">
<div class="col-md-6 col-md-offset-3 vertical-center" id="inner">
<div class="content-holder">
<h3>Some title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</div>
</div>
</div>
</section>
Hope this helps!
Bootstrap newbie here.
I am having trouble getting an accordion to work as desired.
I want to achieve a similar look to the offers on the bottom of this site's slider: http://www.christchurch-harbour-hotel.co.uk/
I am struggling to get the divs to align to the bottom of the row so the accordion opens in an upwards direction. I also experienced problems with the positioning elements in the css where both the columns would overlap.
I'm sure it's just a small thing I am missing. Your help would really be appreciated.
Here is a link to the page I am working on: http://crystalsprings.co.za/newsite/
Here is the relevant html:
.specialblock1_header {
background-color: #df4351;
padding: 10px 15px 10px 15px;
color:#FFF;
font-family:Tahoma, Geneva, sans-serif;
font-size:1.2em;
height:100%;
text-align:left;
outline:none;
border:none;
}
.specialblock1_content {
background-color: #FFF;
padding: 10px 15px 10px 15px;
color:#000;
font-family:Tahoma, Geneva, sans-serif;
font-size:1em;
height:100%;
text-align:left;
}
.specialblock2_header {
background-color: #F96;
padding: 10px 15px 10px 15px;
color:#FFF;
font-family:Tahoma, Geneva, sans-serif;
font-size:1.2em;
height:100%;
text-align:left;
}
.accordian_row {
height:400px;
position: relative;
}
.accordian_row .panel-default{
position: absolute;
margin:0;
}
<div class="row accordian_row">
<div class="col-lg-4"></div>
<div class="col-lg-2">
<div class="panel-group" id="accordion1">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion1" href="#collapse1">Planning your honeymoon?</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div class="col-lg-2">
<div class="panel-group" id="accordion2">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion2" href="#collapse2">Romance in the misty mountains</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4"></div>
</div>
</div>
Try this CSS code:
.panel-collapse{
position: absolute;
bottom: 37px;
}
.accordion_row .panel-default{
position: relative;
margin:0;
}
Link to working fiddle bin:
Bootstrap Accordion align to bottom of div
You need the change the structure in html in order to achieve upward direction
The #collapse1 div should be put above the .panel-heading
demo
<div class="panel-group" id="accordion1">
<div class="panel panel-default">
<div id="collapse1" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div><div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion1" href="#collapse1" class="collapsed" aria-expanded="false">Planning your honeymoon?</a>
</h4>
</div>
</div>
</div>
You can use table's property to achieve this -
Please see the inline styles I have used,
fiddle
<div class="row accordian_row" style="display: table; width: 100%;">
<div style="display: table-row;">
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-4"></div>
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-2">
<div id="accordion1" class="panel-group">
<div style="position: relative;" class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a aria-expanded="true" class="" href="#collapse1" data-parent="#accordion1" data-toggle="collapse">Planning your honeymoon?</a>
</h4>
</div>
<div style="" aria-expanded="true" class="panel-collapse collapse in" id="collapse1">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-2">
<div id="accordion2" class="panel-group">
<div style="position: relative;" class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a aria-expanded="true" class="" href="#collapse2" data-parent="#accordion2" data-toggle="collapse">Romance in the misty mountains</a>
</h4>
</div>
<div style="" aria-expanded="true" class="panel-collapse collapse in" id="collapse2">
<div class="panel-body specialblock1_content">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
</div>
</div>
</div>
</div>
<div style="display: table-cell; height: 100%; vertical-align: bottom; float: none;" class="col-lg-4"></div>
</div>
</div>
.accordian_row .panel-default {
position: absolute;
bottom: 0;
}
.collapse.in, .collapsing {
position: absolute !important;
bottom: 100%;
left: 0;
width: 100%;
}
.panel-group {
margin-bottom: 0;
}
try these codes. it should work fine.