I have 3 divs with anchor tags nested in them. I am trying to reposition them so that they are inline side by side evenly spaced from each other. No matter what I try they just end up overlaying on top each other.
Here is my CSS code
.links {
width: 35%;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 5px;
position: absolute;
}
.absolute {
text-decoration: none;
color: white;
font-size: 11px;
}
.link-container {
padding-left: 5px;
padding-right: 5px;
}
h4 {
font-size: 18px;
margin: 10px;
}
p {
font-size: 14px;
}
Here is my HTML
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
You want to use a flex-box so it's responsive. Here is an example. :)
.container {
display: flex;
flex-wrap: wrap;
}
.links {
flex: 1;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 5px;
}
.absolute {
text-decoration: none;
color: white;
font-size: 11px;
}
.link-container {
padding-left: 5px;
padding-right: 5px;
}
h4 {
font-size: 18px;
margin: 10px;
}
p {
font-size: 14px;
}
<div class="container">
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
</div>
<style>
.container {
padding: 10px
}
.content1 {
margin-left: 0px;
height: 90px;
width: 24%
background: #ddd;
}
.content2 {
background: #3ce223;
height: 90px;
width: 24%;
float: center; /*if that doesn't work than replace it with this: margin-left: 500px; */
}
.content3 {
background: #3dn210o;
height: 90px;
width: 24%;
float: right; /*if that doesn't work than replace it with this: margin-left: 1000px; or at least until it is right of the screen */
}
</style>
<div class="container">
<div class="content1">
</div>
<div class="content2">
</div>
<div class="content3">
</div>
</div>
If none of that works please comment and I will address the issue
Try this out.
.container {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.links {
width: 35%;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 5px;
}
.absolute {
text-decoration: none;
color: white;
font-size: 11px;
}
.link-container {
padding-left: 5px;
padding-right: 5px;
}
h4 {
font-size: 18px;
margin: 10px;
}
p {
font-size: 14px;
}
<div class="container">
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
<div class="links">
<div class="link-container">
<a class="absolute" href="#">
<h4>Lorem Ipsum</h4>
<hr>
<p>
is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen.
</p>
</a>
</div>
</div>
</div>
The div element is displayed as a block element by default, display: block in code. This has to be changed.
The given position: absolute makes all the elements appear at the same spot.
On top of this the blocks including their added margins and paddings do not fit on the whole width of the page. This also needs adjustments.
Change your css .links and .link-container declarations:
.links {
width: 30%;
text-align: center;
border: solid 1px;
background-color: #02b316;
margin: 1%;
position: relative;
display: inline-block;
}
.link-container {
padding-left: 1%;
padding-right: 1%;
}
Related
I have the bellow code and as a newbie I'm struggling to make the button stay in line at the bottom of the div no matter how long the text above it is. I also want to keep the divs aligned at the top as well. Any help is appreciated.
Thank you!
edit: What I would like to achieve is something like how they did their packages (everything stays in place/buttons at the bottom of the box when the window is made smaller):
https://www.knownhost.com/
.div1{width:90%;height:100%;max-width:1920px;margin:2.5em auto}
.div2{vertical-align:top;width:32%;margin:0 0 2em .5%;display:inline-block}
.image {background-color:#0d0d0d}
.image1{float:left;width:100%;border:1px solid #d7d7d7;margin-bottom: .8em}
.title{color:#55068f;font:20px robotoregular;text-align:center;padding:3em 0 0}
.text{width:85%;margin:1em auto 0;text-align:center;padding-bottom:34px;font:16px robotolight;height:auto;color:#313030;line-height:1.4em}
.button a,.button a:hover{text-decoration:none;margin:0 auto}
.button a{font:19px robotolight;color:#55068f;text-align:center;border:thin solid #55068f;padding:.8em 2em;width:40%}
.button a:hover{color:#0d0d0d;border:thin solid #FFD83A;background-color:#FFD83A}
.button{text-align:center;}
<div class="div1">
<div class="div2">
<div class="image"><img src="" class="image1" alt=""></div>
<div class=content>
<div class=title>Title</div>
<div class=text><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</div>
</div>
<div class=button><a href="" class=custom_btn>find out more</a></div>
</div>
<div class="div2">
<div class="image"><img src="" class="image1" alt=""></div>
<div class=content>
<div class=title>Title</div>
<div class=text><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy</div>
</div>
<div class=button><a href="" class=custom_btn>find out more</a></div>
</div>
<div class="div2">
<div class="image"><img src="" class="image1" alt=""></div>
<div class=content>
<div class=title>Title</div>
<div class=text><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</div>
</div>
<div class=button><a href="" class=custom_btn>find out more</a></div>
</div>
</div>
Did you mean something like that? :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
.div1{
width:90%;
margin:2.5em auto;
}
.div2{
vertical-align:top;
width:32%;
margin:0 0 2em .5%;
display:inline-block;
position: relative;
height: 100%;
}
.image {
background-color:#0d0d0d
}
.image1{
float:left;
width:100%;
border:1px solid #d7d7d7;
margin-bottom: .8em
}
.title{
color:#55068f;
font:20px robotoregular;
text-align:center;
padding:3em 0 0
}
.text{
width:85%;
margin:1em auto 0;
text-align:center;
padding-bottom:34px;
font:16px robotolight;
height:auto;color:#313030;
line-height:1.4em
}
.button a {
background-color: #fff;
}
.button a,.button a:hover{
text-decoration:none;margin:0 auto
}
.button a{
font:19px robotolight;
color:#55068f;
text-align:center;
border:thin solid #55068f;
padding:.8em 2em;
width:40%;
}
.button a:hover{
color:#0d0d0d;
border:thin solid #FFD83A;
background-color:#FFD83A
}
.button{
text-align:center;
}
.content {
position: relative;
overflow-y: auto;
display: inline;
}
.div1 {
position: absolute;
top: 20px;
bottom: 20px;
left: 0;
right: 0;
}
.div2 {
height: 100%;
}
.div2-wrap {
display: block;
height: 90%;
overflow-x: hidden;
overflow-y: auto;
}
.div2 .image {
height: 40%;
}
.div2 .content {
height: 50%;
}
.div2 .button {
height: 10%;
padding: 10px 0;
}
.div2 .button a {
display: inline-block;
margin-top: -6px;
}
#main {
position: absolute;
top: 100%;
}
</style>
</head>
<body>
<div class="div1">
<div class="div2">
<div class="div2-wrap">
<div class="image"><img src="" class="image1" alt=""></div>
<div class=content>
<div class=title>Title</div>
<div class=text><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 1500sLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500sLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500sLorem 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 class=button><a href="" class=custom_btn>find out more</a></div>
</div>
<div class="div2">
<div class="div2-wrap">
<div class="image"><img src="" class="image1" alt=""></div>
<div class=content>
<div class=title>Title</div>
<div class=text><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy</p></div>
</div>
</div>
<div class=button><a href="" class=custom_btn>find out more</a></div>
</div>
<div class="div2">
<div class="div2-wrap">
<div class="image"><img src="" class="image1" alt=""></div>
<div class=content>
<div class=title>Title</div>
<div class=text><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 class=button><a href="" class=custom_btn>find out more</a></div>
</div>
</div>
<div id="main">
<p>Put your content here</p>
</div>
</body>
</html>
Trying to get the paragraph to be the same size as the image on the right as it. currently it is the bottom of the paragraph changes size but the top is fixed
kid with toy cars
my CSS code is
.kid{
display: flex;
position: relative;
float: right;
height: auto;
max-width: 50%;
}
.paragraph{
display: flex;
margin-right: 50%;
font-size-adjust: auto;
background-color: #3498db;
color:white;
font-style: italic;
font-weight: bold;
}
and my HTML code is
<div>
<img class = "kid" src="kid%20playing%20toy%20pic.jpg">
</div>
<div class = "para">
<section class="paragraph">
<p> "text" </p>
</section>
</div>
Because you want the size of the image to be dynamic with the length of the paragraph, I would use a 2-column flex layout with the second div containing the image as background-image. Do it this way is responsive because the height of the image-div will change as the paragraph gets smaller or larger.
.wrapper {
display: flex;
width: 100%;
flex: auto;
}
.paragraph {
background-color: #3498db;
color: white;
font-style: italic;
font-weight: bold;
width: 50%;
}
.image-div {
background-image: url('https://dummyimage.com/600x400/000/fff');
background-position: center;
background-size: cover;
width: 50%;
}
<h6> smaller </h6>
<div class="wrapper">
<div class="paragraph">
<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, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged </p>
</div>
<div class="image-div">
</div>
</div>
<h6> larger </h6>
<div class="wrapper">
<div class="paragraph">
<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, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. 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, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. Lorem Ipsum
is simply dummy text of the printing and typesetting industry.</p>
</div>
<div class="image-div">
</div>
</div>
not entirely clear what you actually want. Use flex.
.paragraph {
display: flex;
justify-content:space-between;
background-color: #3498db;
color: white;
font-style: italic;
font-weight: bold;
}
<section class="paragraph">
<p> "text" </p>
<img class="kid" src="https://via.placeholder.com/150">
</section>
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
.textarea {
display: block;
width: 400px;
margin-bottom: 20px;
border: 1px solid black;
overflow: hidden;
white-space: nowrap;
}
.clip {
text-overflow: clip;
}
.ellipsis {
text-overflow: ellipsis;
}
<div class="textarea clip">
<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, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five </p>
</div>
<div class="textarea ellipsis">
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</div>
Here after setting the value text-overflow:ellipsis ,I am not getting three dot(...) which should come ,if there is more text given that width is not so much enough to accommodate all the text.
I have tried with different width values but no required result is coming.
Because overflow and text-overflow in not an inherited property and you have applied it on .textarea so no effect on the <p> will take place.
You can apply white-space:nowrap to the .textarea as it is an inherited css property.
So apply overflow:hidden and text-overflow to the <p> instead of .textarea..
Also you have a typo error in your above code...textarea will be .textarea because its a class not a tag
Stack Snippet
.textarea {
display: block;
width: 400px;
margin-bottom: 20px;
border: 1px solid black;
white-space: nowrap;
}
.clip p {
text-overflow: clip;
overflow: hidden;
}
.ellipsis p {
text-overflow: ellipsis;
overflow: hidden;
}
<div class="textarea clip">
<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, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five </p>
</div>
<div class="textarea ellipsis">
<p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
</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>