I have multiple items say cards. These cards need to stack horizontally and height needs to be the same. This is happening for me.
Each card has an image, text and a button. Image and text for each card should take what ever is the max height in any card, so that these align properly. This is not happening for me.
If the image and text align properly then the button will always be aligned in each card at the bottom.
I have been following this tutorial but I have multiple cards, putting three here only. Also the third card image height is being set via CSS.
.partner-cards * {
box-sizing: border-box;
}
.partner-cards {
display: flex;
flex-wrap: wrap;
}
.partner-card {
display: flex;
flex: 1 0 20%;
border-radius: 0;
text-align: center;
border: 3px solid blue;
padding: 5px;/*3rem;*/
margin-bottom: 3rem;
max-width: 20%;
margin: 5px;
}
.partner-card-content {
display: flex;
flex-direction: column;
}
/*
.card-content .image-container img {
margin: 0;
padding: 0;
}
*/
.partner-card-content .partner-image-container {
border: 1px solid green;
padding: 0;
margin: 0;
min-height: 11rem;
display: flex;
vertical-align: middle;
align-items: center;
justify-content: center;
max-width: 100%;
}
.partner-card-content p /*, .card-content .image-container*/
{
flex: 1 0 auto;
border: 1px solid red;
}
.partner-card-content img.third-image {
height: 5.5rem !important;
}
/*
p {
font-size: 16px;
line-height: 26px;
font-family: Averta-Regular,Arial,Helvetica,sans-serif;
margin-bottom: 2.5rem;
margin-top: 0;
}*/
<div class="partner-cards">
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/100x40" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View XXX XXX XXX Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x150" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View YYY Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/120x100" class="third-image" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
<a class="primary-button" href="#">View ZZZ Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x100" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
<a class="primary-button" href="#">View ABC Offer</a>
</div>
</div>
</div>
How it should show:
The tutorial image on code pen, properly aligns the h2, text and link:
TL;DR
Alignment of flexbox items in adjacent flexboxes is not possible in CSS. You really need sub-grids to solve this problem with dynamic sizes of the sections in your card.
Flexbox Scenario
Anyway given that you have a min-height for the partner-image-container, so I guess you can have either a min-height set for the a or an ellipsis to keep it to a single line. See below solution that adds an ellipsis:
.partner-cards * {
box-sizing: border-box;
}
.partner-cards {
display: flex;
flex-wrap: wrap;
}
.partner-card {
display: flex;
flex: 1 0 20%;
border-radius: 0;
text-align: center;
border: 3px solid blue;
padding: 5px;/*3rem;*/
margin-bottom: 3rem;
max-width: 20%;
margin: 5px;
}
.partner-card-content {
display: flex;
flex-direction: column;
min-width: 0; /* ADDED */
}
/*
.card-content .image-container img {
margin: 0;
padding: 0;
}
*/
.partner-card-content .partner-image-container {
border: 1px solid green;
padding: 0;
margin: 0;
min-height: 11rem;
display: flex;
vertical-align: middle;
align-items: center;
justify-content: center;
max-width: 100%;
}
.partner-card-content p/*, .card-content .image-container*/ {
flex: 1 0 auto;
border: 1px solid red;
}
.partner-card-content img.third-image {
height: 5.5rem !important;
}
/*
p {
font-size: 16px;
line-height: 26px;
font-family: Averta-Regular,Arial,Helvetica,sans-serif;
margin-bottom: 2.5rem;
margin-top: 0;
}*/
.primary-button { /* ADDED */
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
<div class="partner-cards">
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/100x40" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View XXX XXX XXX Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x150" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View YYY Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/120x100" class="third-image" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
<a class="primary-button" href="#">View ZZZ Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x100" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
<a class="primary-button" href="#">View ABC Offer</a>
</div>
</div>
</div>
Note that you'll have to add min-width: 0 to partner-card-content to override the default min-width: auto setting for a flexbox in the flex axis. You can see some examples of this behaviour below:
Flexbox affects overflow-wrap behavior
Flexbox resize and scrollable overflow
Why don't flex items shrink past content size?
CSS Grid Scenario
You can do this in a different way using CSS Grid Layout - as an example consider 3 cards laid out in a row. This works for dynamic heights of each of your card sections - see demo below:
.partner-cards * {
box-sizing: border-box;
}
.partner-cards {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: auto 1fr auto;
grid-auto-flow: column;
grid-column-gap: 10px;
}
.partner-card, .partner-card-content {
display: contents;
}
.partner-card-content .partner-image-container {
border: 1px solid green;
display: flex;
align-items: center;
justify-content: center;
max-width: 100%;
}
.partner-card-content p {
border: 1px solid red;
margin: 0;
}
.partner-card-content a {
border: 1px solid;
}
<div class="partner-cards">
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/100x40" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View XXX XXX XXX Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/50x150" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s.</p>
<a class="primary-button" href="#">View YYY Offer</a>
</div>
</div>
<div class="partner-card">
<div class="partner-card-content">
<div class="partner-image-container">
<img src="https://via.placeholder.com/120x100" class="third-image" alt="">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s. Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
<a class="primary-button" href="#">View ZZZ Offer</a>
</div>
</div>
</div>
But again it has limitations because you are not able to control your layout - you don't have control over your cards but you are working on the contents of the cards here which is not very useful. Note that I have used display: contents for the partner-card and partner-card-content elements. When sub-grids are implemented, we will have a complete solution to layouts such as this - see the discussion below too:
Wrap CSS grid with auto placement
Related
I'm using Bootstrap cards and I want to separate them by a 2px margin.
Nonetheless, when I apply it (either with Bootstrap's margin classes or directly on my stylesheet) flex-wrap triggers and a card goes one row down.
How could I deal with this behavior?
Should I give a max-width to the cards?
.dark-theme body,
.dark-theme .card {
background-color: #121212;
color: #ffffffa6;
}
.dark-theme section.card {
background-color: #464646;
}
.card {
border-width: 0;
margin: 3px;
}
main {
padding: 100px;
}
h1 {
text-align: center;
}
h2,
.card {
margin-top: 20px;
}
.dark-theme .btn {
background-color: salmon;
border-color: salmon;
}
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<div class="highlights row">
<section class="card col-md-6 col-lg-4">
<h3>Where does it come from?</h3>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</p>
<p>orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
when an unknown
</section>
<section class="card col-md-6 col-lg-4">
<h3>Where does it come from?</h3>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</p>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</p>
<a href="#" class="card__btn btn btn-info">
when an unknown
</a>
</section>
<section class="card col-md-6 col-lg-4">
<h3>Where does it come from?</h3>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
<a href="#" class="card__btn btn btn-info">
when an unknown
</a>
</section>
First and foremost, remove any margins set on Bootstrap classes. Bootstrap is intended to not need to add spacing/sizing, as it is built into the classes.
I re-worked your structure quite a bit. Mostly to try to structure the elements as Bootstrap recommends. With that being said, don't nest each card in sections. Instead, nest them in divs. The <section> tag defines a section in a document. & if I am not mistaken, the three cards aligned in a row qualify as a section. I nested all three cards in one section and called it the highlights class you already had.
col's function as a method of reserving space for certain content. So with a three-card setup, you should use col-4. The largest col is col-12, which spans the full width of the screen. 12/4 = 3. Then you can use sm lg and md for responsiveness on media screens. The above example creates three equal-width columns on small, medium, large, and extra-large devices using the predefined grid classes. Those columns are centered on the page with the row parent.
With this being said, the main reason your code was not working as intended is the additional CSS margins and that the cards should be nested in the col's. Lastly, the misuse of column sizing as mentioned previously.
I'd suggest brushing up on the Bootstrap Grid System. You can build a fully responsive site with little knowledge in CSS if you know Bootstrap.
.dark-theme body,
.dark-theme .card {
background-color: #121212;
color: #ffffffa6;
}
.dark-theme section.card {
background-color: #464646;
}
.card {
border-width: 0;
}
main {
padding: 100px;
}
h1 {
text-align: center;
}
.dark-theme .btn {
background-color: salmon;
border-color: salmon;
}
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<section class="highlights">
<div class="row w-100 m-0 justify-content-center">
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card w-100">
<h3>Where does it come from?</h3>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</p>
<p>orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
when an unknown
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card w-100">
<h3>Where does it come from?</h3>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</p>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
</p>
<a href="#" class="card__btn btn btn-info">
when an unknown
</a>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card w-100">
<h3>Where does it come from?</h3>
<p>
orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
<a href="#" class="card__btn btn btn-info">
when an unknown
</a>
</div>
</div>
</div>
</section>
Here, You can used Gutters class in the Bootstrap grid system.
Gutters are the gaps between column content, created by horizontal padding. We set padding-right and padding-left on each column, and use negative margin to offset that at the start and end of each row to align content.
You can use g-1, g-2, g-3, g-4, and g-5 in row according to your needs.
.dark-theme body, .dark-theme .card {background-color: #121212; color: #ffffffa6;}
.dark-theme section.card {background-color: #464646;}
.card {border-width: 0;}
main {padding: 100px;}
h1 {text-align: center;}
.dark-theme .btn {background-color: salmon;border-color: salmon;}
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<section class="highlights">
<div class="row justify-content-center g-1">
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card">
<h3>Where does it come from?</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
when an unknown
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card">
<h3>Where does it come from?</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p>when an unknown
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card">
<h3>Where does it come from?</h3>
<p>orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p><p>orem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
when an unknown
</div>
</div>
</div>
</section>
Does anyone know how to use the following css trick with inline-blocks?
.text {
display: block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
I have couple of text tags (h2 & h3) on the same line and even if I change the display: block to inline-block, it still messes up the layout.
Has anyone done anything similar?
EDIT: I only want to concatenate the h2 (first element), not the h3 tag content.
try this
p{
display: inline-block;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<p class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</p>
Try to use line-height for class text with display:inline-block
.text{
display: inline-block;
/* adjust line height for class text*/
line-height: 25px;
width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
</h3>
.text {
display: inline-block;
line-height:20px;
width: 200px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
<h2 class="text">this is Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h2>
<h3 class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy.
</h3>
I need to move my search box when user focus on it. I am using css animation and that is working but not working fine. I want to make like the current search box is moving up but right now it is seems like new search box is replacing the current search box.
$('input').focus(function(){
$('.search').addClass('fixed');
})
$('input').blur(function(){
$('.search').removeClass('fixed');
})
body{
margin:0
}
.banner{
height:200px;
background:#ff0000
}
.search{}
.search-bar{ height:50px; background:#666; padding-top:10px}
.search-bar input{width:100%; height:35px}
.animated{background:#fff; opacity:0; position:fixed; bottom:0; height:0px; transition:height 0.5s; width:100%}
.fixed .animated{ height:100%; opacity:1}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>
<div class="banner">
</div>
<div class="search">
<div class="search-bar">
<input type="text">
</div>
<div class="animated">
<div class="search-bar">
<input type="text">
</div>
</div>
</div>
<div class="body">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
</div>
</div>
Here is a sample having the same animation using only 1 search box (input)
$('input').focus(function(){
$('.search').addClass('fixed');
})
$('input').blur(function(){
$('.search').removeClass('fixed');
})
html, body {
margin: 0
}
.banner {
height: 200px;
background: #ff0000
}
.search-bar {
height: 50px;
background: #666;
padding-top: 10px
}
.search-bar input {
width: 100%;
height: 35px
}
.search {
transition: bottom 0.5s, top 0.5s;
background: #ddd;
width: 100%;
min-height: 50px;
top: 200px;
bottom: 40%;
}
.search.fixed {
transition: bottom 0.5s, top 0.5s;
top: 0;
bottom: 0;
position: fixed;
width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div>
<div class="banner">
</div>
<div class="search">
<div class="search-bar">
<input type="text">
</div>
</div>
<div class="body">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
</p>
</div>
</div>
I have kinda complex situation here (at least complex for me). Attached a fiddle to show how I was trying to accomplish this.
I wanted to position the speech bubble in the center of the black line of the yellow image. (shown in fiddle).
Also, when I go down to smaller devices the text flows beneath the speech bubble. (you can re-size the window and see)
All of these must be shown at a 100 vh height meaning, users need not scroll to see the bubble as well as image.
Fiddle Link to show what I was doing
<div class="container" id="about_container">
<div class="row" id="row_about_1">
<div class="col-lg-2 col-md-2 col-xs-2 col-sm-2"></div>
<div class="col-lg-8 col-md-8 col-xs-8 col-sm-8 bubble">
<div class="abt_txtcontainer">
<p class="abt_maintext">Heading</p>
<p class="abt_subtxt">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p class="abt_maintext">Heading</p>
<p class="abt_subtxt">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p class="abt_maintext">Heading</p>
<p class="abt_subtxt">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
</div>
<div class="col-lg-2 col-md-2 col-xs-2 col-sm-2"></div>
</div>
<div class="row" id="row_about_2">
<div class="col-lg-2"></div>
<div class="col-lg-8">
<img src="http://i.imgur.com/5T5N5Vn.png" class="about_bg img-responsive">
</div>
<div class="col-lg-2"></div>
</div>
</div>
Try this code:
.bubble {
position: relative;
z-index: 1;
/*width: 80%;*/
height: auto;
/* margin-left:12.5%;*/
padding: 5%;
background: #2e3c6f;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
color:darkgrey;
}
.bubble:after {
content: '';
position: absolute;
border-style: solid;
border-width: 32px 21px 0;
border-color: #2e3c6f transparent;
display: block;
width: 0;
z-index: 1;
margin-left: -10.5px;
bottom: -32px;
left: 50%;
}
.about_bg {
width: 100%;
height: auto;
}
#about_container {
height: 100vh;
margin-top: 2.5%;
}
#row_about_1 {
height: 80vh;
}
#row_about_2 {
height: 20vh;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="container" id="about_container">
<div class="row" id="row_about_1">
<div class="col-lg-2 col-md-2 col-xs-2 col-sm-2"></div>
<div class="col-lg-8 col-md-8 col-xs-8 col-sm-8 bubble">
<div class="abt_txtcontainer">
<p class="abt_maintext">Heading</p>
<p class="abt_subtxt">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p class="abt_maintext">Heading</p>
<p class="abt_subtxt">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p class="abt_maintext">Heading</p>
<p class="abt_subtxt">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
</div>
<div class="col-lg-2 col-md-2 col-xs-2 col-sm-2"></div>
</div>
<div class="row" id="row_about_2">
<div class="col-lg-2"></div>
<div class="col-lg-8">
<img src="http://i.imgur.com/5T5N5Vn.png" class="about_bg img-responsive">
</div>
<div class="col-lg-2"></div>
</div>
</div>
Solution:
1) To set bubble arrow in center:
--> Added position absolute and left value 50%, then added margin-left 10.5% (it's the half width of arrow)
2) Overlapping content:
--> Set bubble height auto (which was 80% previously), now when you'll resize browser it'll not get disturbed.
You probably wanted more fluid solution but with media queries you can adjust image size and position bubble from bottom on larger screens. Just add one more step, eg. on screens > 1200px.
To avoid overflowing I would keep min-height of container...
.about-container {
height: 100vh;
min-height: 580px;
}
.about-container .wrap {
position: relative;
height: 100%;
}
.bubble {
background: #2e3c6f;
color: #fff;
position: absolute !important;
bottom: 150px;
left: 0;
padding: 30px;
border-radius: 15px;
z-index: 1;
}
.bubble:after {
position: absolute;
content: '';
top: 100%;
left: 50%;
height: 0;
width: 0;
border: solid transparent;
border-top-color: #2e3c6f;
border-width: 30px;
margin-left: -30px;
}
p:last-child {
margin-bottom: 0;
}
.about-img {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: 0 auto;
max-width: 320px;
height: auto;
}
<html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<body>
<div class="container about-container">
<div class="wrap">
<div class="col-xs-12 col-md-8 col-md-offset-2 bubble">
<p>Heading</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p>
<p>Heading</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
<p>Heading</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p>
</div>
<img src="http://i.imgur.com/5T5N5Vn.png" class="about-img">
</div>
</div>
</body>
</html>
I have a sample page as shown below
HTML code:
<div class="container">
<div class="header floatL width100p">
<h2>
Header
</h2>
</div>
<div class="content floatL width100p">
<div class="floatL width29p npv">
<p>navigation div</p>
</div>
<div class="floatL width70p rtb">
<div class="floatL width100p ql">
<p>
div one
</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
<div class="floatL width100p mtbs">
<p>
div two
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
<div class="floatL width100p widdiv">
<div class="floatL width100p">
<div class="floatL width40p incont">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
<div class="floatL width40p incont">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
</div>
<div class="floatL width100p">
<div class="floatL width40p incont">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
<div class="floatL width40p incont">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</p>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<div class="footer floatL width100p">
<h2>
Footer
</h2>
</div>
<div class="clear"></div>
</div>
The styles are:
*,html{
margin: 0;
padding: 0;
}
.container{
width:960px;
margin:20px auto;
}
.header h2,.footer h2{
text-align: center;
}
.floatL{
float: left;
}
.floatR{
float: right;
}
.clear{
clear:both;
}
.width100p{
width: 100%;
}
.width29p{
width: 29%;
}
.width70p{
width: 70.8%;
}
.header,.footer,.content{
border:1px solid;
}
.npv{
border-right: 1px solid;
height: 100%;
}
.ql,.mtbs{
border-bottom: 1px solid;
}
.width40p{
width: 40%;
}
.incont{
margin: 4%;
background: #ccc;
border:1px solid red;
}
I would like to know why the left navigation div is not occupying 100% height as you can see by running the above code.
Any help would be appreciated. It is urgent...
Use css tables
FIDDLE
CSS
.content
{
display: table;
height: 100%;
}
.npv, .rtb
{
display: table-cell;
}
If you want to know more about the problem than simply fix it, this is a nice article that explains the problem and give you multiple solutions: Fluid Width Equal Height Columns