Border length of child div have width same parent div? - html

I want to add a border-bottom between to post. But my post created by featured image and except wrap by parent div.
Like this:
.wrapper {
position: relative;
padding-bottom: 48px;
}
.thumbnail {
position: absolute;
left: 0;
top: 0;
}
.except {
margin-left: 350px;
min-height: 235px;
border-bottom: solid 1px #000;
}
<div class="wrapper">
<div class="thumbnail">
<img width="324" height="212" src="https://sharengay.com/wp-content/uploads/2018/07/banner-thu-thuat-xem-phim-netflix-324x212.jpg">
</div>
<div class="except">
<span> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</span>
</div>
</div>
<div class="wrapper">
<div class="thumbnail">
<img width="324" height="212" src="https://sharengay.com/wp-content/uploads/2018/07/banner-thu-thuat-xem-phim-netflix-324x212.jpg">
</div>
<div class="except">
<span> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</span>
</div>
</div>
By some reason, I must add border-bottom in class except but it only draw a line for this element. I want to the property border-bottom is full in element wrapper.
You can test on production website at here: https://sharengay.com
You can see currently like this:

Just wrap it in a div
.wrapper {
position: relative;
padding-bottom: 48px;
}
.thumbnail {
position: absolute;
left: 0;
top: 0;
}
.except {
margin-left: 350px;
min-height: 235px;
}
.subwrapper { /* Target */
border-bottom: 2px solid #000;
margin-bottom: 20px;
}
<div class="wrapper">
<div class="subwrapper">
<div class="thumbnail">
<img width="324" height="212" src="https://sharengay.com/wp-content/uploads/2018/07/banner-thu-thuat-xem-phim-netflix-324x212.jpg">
</div>
<div class="except">
<span> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</span>
</div>
</div>
<div class="wrapper">
<div class="thumbnail">
<img width="324" height="212" src="https://sharengay.com/wp-content/uploads/2018/07/banner-thu-thuat-xem-phim-netflix-324x212.jpg">
</div>
<div class="except">
<span> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</span>
</div>
</div>
https://stackblitz.com/edit/angular-mpunwb

Do I understand correctly : you want border-bottom along the entire length of wrapper ?
if so you need to remove margin-left: 350px;
.except {
min-height: 235px;
border-bottom: solid 1px #000;
}
Code Snippet:
.wrapper {
position: relative;
padding-bottom: 48px;
}
.thumbnail {
position: absolute;
left: 0;
top: 0;
}
.except {
min-height: 235px;
border-bottom: solid 1px #000;
}
<div class="wrapper">
<div class="thumbnail">
<img width="324" height="212" src="https://sharengay.com/wp-content/uploads/2018/07/banner-thu-thuat-xem-phim-netflix-324x212.jpg">
</div>
<div class="except">
<span> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</span>
</div>
</div>
<div class="wrapper">
<div class="thumbnail">
<img width="324" height="212" src="https://sharengay.com/wp-content/uploads/2018/07/banner-thu-thuat-xem-phim-netflix-324x212.jpg">
</div>
<div class="except">
<span> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</span>
</div>
</div>

Related

Other divs overlap behind if I use percentages

I am experiencing a problem in CSS where my other divs overlap to the image above if I use percentages, for px I have no problem and the divs stay in place. I want the image to be in full-width size though as like a hero image and want it responsive in all screen sizes.
Screenshot of site
.img-slider{
position: relative;
width: 100%;
height: 300px;
margin-bottom: 90px;
background: #18191C;
}
.img-slider .slide{
z-index: 1;
position: absolute;
width: 100%;
clip-path: circle(0% at 0 50%);
}
.img-slider .slide.active{
clip-path: circle(150% at 0 50%);
transition: 1.3s;
transition-property: clip-path;
}
.img-slider .slide img{
z-index: 1;
width: 100%;
width: 100%;
border-radius: 5px;
}
<div class="img-slider">
<div class="slide active">
<img src="images/Thumb/img1.png" alt="">
<div class="info">
<h2>Native Fixtures</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="slide">
<img src="images/Thumb/img2.png" alt="">
<div class="info">
<h2>Slide 02</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="slide">
<img src="3.jpg" alt="">
<div class="info">
<h2>Slide 03</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="slide">
<img src="4.jpg" alt="">
<div class="info">
<h2>Slide 04</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="slide">
<img src="5.jpg" alt="">
<div class="info">
<h2>Slide 05</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
If you use flex box with the justify-content:space-around setting and flex-grow you can create the effect your looking for.
https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Make columns equal heights

I am working on 2 columns made with Bootstrap 3. We cannot change to Bootstrap 4 at the moment, since we are having a webshop with over 100.000 products. So that is a project for the future, since we do not have time right now. Therefore solutions with solve the below problem with Bootstrap 4 is not an option right now.
At the moment I am working with Bootstrap 3. I am having some problems make my columns equal heights. The right is smaller than the left one.
Does anybody know a good solution, so the columns are having equal height - even if the viewport is changing? It does not matter when the viewport is mobile.
There is a JSFiddle here
.row [class*="col-"] {
padding-right: 7.5px;
padding-left: 7.5px;
}
.padding-twocolumn-bg {
margin-bottom:30px;
}
.business-left-img a img {
width: auto;
margin:auto
}
.business-left {
padding:75px 75px 40px 75px;
}
.classWithPad {
margin:8px;
padding:10px;
background-color: #fff;
border:1px solid #ebecf0;
}
<div class="wrapper">
<!-- Section 7 -->
<div class="section padding-twocolumn-bg">
<div class="row">
<div class="text-center col-md-6 business-left-img">
<div class="classWithPad">
<p class="business-left">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a><img src="https://placehold.it/150x150" class="img-responsive"></a>
<h2>AGA-Tools</h2>
<p>Name - Position</p>
+45 12 34 56 78
</div>
</div>
<div class="text-center col-md-6">
<div class="classWithPad">
<div class="row">
<div class="col-sm-12">
<h3 class="sbp-align">Headline</h3>
<hr>
</div>
<div class="col-sm-6">
<a href="#">
<img src="https://placehold.it/250x150" style="padding:10px;">
</a>
<h4 class="sbp-align">Subline</h4>
<p class="sbp-align">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<hr id="sbp-hr">
Ansøg nu
</div>
<div class="col-sm-6">
<img src="https://placehold.it/250x150" style="padding:10px;">
<h4 class="sbp-align">Subline</h4>
<p class="sbp-align">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<hr id="sbp-hr">
Read more
</div>
</div>
</div>
</div>
</div>
</div>
</div>
.row [class*="col-"] {
padding-right: 7.5px;
padding-left: 7.5px;
}
.padding-twocolumn-bg {
margin-bottom:30px;
}
.business-left-img a img {
width: auto;
margin:auto
}
.business-left {
padding:75px 75px 40px 75px;
}
.classWithPad {
margin:8px;
padding:10px;
background-color: #fff;
border:1px solid #ebecf0;
height: 100%;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" />
<div class="wrapper">
<!-- Section 7 -->
<div class="section padding-twocolumn-bg">
<div class="row">
<div class="text-center col-md-6 business-left-img">
<div class="classWithPad">
<p class="business-left">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<a><img src="https://placehold.it/150x150" class="img-responsive"></a>
<h2>AGA-Tools</h2>
<p>Name - Position</p>
+45 12 34 56 78
</div>
</div>
<div class="text-center col-md-6">
<div class="classWithPad">
<div class="row">
<div class="col-sm-12">
<h3 class="sbp-align">Headline</h3>
<hr>
</div>
<div class="col-sm-6">
<a href="#">
<img src="https://placehold.it/250x150" style="padding:10px;">
</a>
<h4 class="sbp-align">Subline</h4>
<p class="sbp-align">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<hr id="sbp-hr">
Ansøg nu
</div>
<div class="col-sm-6">
<img src="https://placehold.it/250x150" style="padding:10px;">
<h4 class="sbp-align">Subline</h4>
<p class="sbp-align">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<hr id="sbp-hr">
Read more
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You can add
.classWithPad {
height: 100%;
}
or
.business-left {
padding: 37px 75px 40px 75px;
}
You can do it in many different ways, by playing with the paddings and margins, but I think the hieght: 100% is the proper way to do it.

Flex: Image top, text bottom. Expand remaining height with aspect ratio image.

I'm trying to create a simple design, image on top, text underneath. I'm using flexbox.
I want to keep the images the same ratio so I'm using the padding top aspect ratio hack to do so, that works well.
What I'm struggling with is getting the text box beneath the image to take up the rest of the remaining space in the container. I was hoping that flexbox would make this easy but I think using it in conjunction with the aspect ratio hack is causing issues.
Here's a fiddle of the basic layout https://codepen.io/anon/pen/NEqdyN. Can anyone help me make each of the red boxes expand to fill the remaining height? I also need to add a border radius the bottom of each corner so I can't use the overflow hidden method.
Thanks in advance!
Code below
<div class="container">
<div class="card">
<div class="image-wrapper">
<img src="https://via.placeholder.com/350x150?Text=Image">
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
<div class="card">
<div class="image-wrapper">
<img src="https://via.placeholder.com/350x150?Text=Image">
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
<div class="card">
<div class="image-wrapper">
<img src="https://via.placeholder.com/350x150?Text=Image">
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
<br><br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
</div>
CSS
body {
margin: 0;
}
.container {
display: flex;
}
.card {
width: 30%;
margin: 0 1%
}
.image-wrapper {
height: 0;
padding-bottom: 56.25%;
position: relative;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
position: absolute;
top: 0;
left: 0;
}
.text {
background: red;
padding: 20px
}
It should work by defining a flex container on each card and using flex: 1 0 auto on text blocks.
.card {
display: flex;
flex-direction: column;
}
.text {
flex: 1 0 auto;
}
Demo
body {
margin: 0;
}
.container {
display: flex;
}
.card {
display: flex;
flex-direction: column;
width: 30%;
margin: 0 1%;
}
.image-wrapper {
height: 0;
padding-bottom: 56.25%;
position: relative;
}
img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
position: absolute;
top: 0;
left: 0;
}
.text {
background: red;
padding: 20px;
flex: 1 0 auto;
}
<div class="container">
<div class="card">
<div class="image-wrapper">
<img src="https://via.placeholder.com/350x150?Text=Image">
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
<div class="card">
<div class="image-wrapper">
<img src="https://via.placeholder.com/350x150?Text=Image">
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
<div class="card">
<div class="image-wrapper">
<img src="https://via.placeholder.com/350x150?Text=Image">
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
<br><br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
</div>

Expand div to text length with absolute positioned elements

I am trying to create some container divs in a column and which have a paragraph within them of varying length.
I'd like to expand the div to the correct height to allow for all the text however as my elements are set as positioned: absolute, I think it is causing an issue.
Please see me fiddle: http://jsfiddle.net/p7pue2kx/1/
In the first box, the text fits nicely. However when the text is much longer, it overflows and the div container does not expand accordingly. I'd like to ensure there is a min-height but the max is determined by the text size.
Are there any better ways of doing this positioning that may allow for my text to expand the container.
Thanks in advance.
Don't use absolute positioning where there is no need to use it :)
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.masterContainer {
height: 800px;
background: blue;
width: 300px;
}
.container {
position: relative;
width: 100%;
background: yellow;
min-height: 60px;
margin: 10px 0px;
padding: 10px;
}
.summary {
clear: both;
width: 100%;
overflow: hidden;
background: lightblue;
}
.id {
float: left;
background: green;
}
.xyz {
float: right;
background: red;
}
<div class="masterContainer">
<div class="container">
<div class="id">
KEY / ID
</div>
<div class="xyz">ABCD EFGH</div>
<div class="summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</div>
</div>
<div class="container">
<div class="id">
KEY / ID
</div>
<div class="xyz">ABCD EFGH</div>
<div class="summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
</div>
<div class="container">
<div class="id">
KEY / ID
</div>
<div class="xyz">ABCD EFGH</div>
<div class="summary">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>
</div>
</div>
Always avoid absolute positioning when possible. Here is one solution with minimal CSS to accomplish what you want.
CSS:
.masterContainer {
height: 800px;
background: blue;
width: 300px;
}
.container {
width: 300px;
background: yellow;
margin: 10px 0px;
}
.summary {
background: lightblue;
display: block;
}
.id {
background: green;
}
.xyz {
background: red;
float: right;
}
HTML:
<div class="container">
<span class="id">
KEY / ID
</span>
<span class="xyz">ABCD EFGH</span>
<span class="summary">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</span>
</div>
<div class="container">
<span class="id">
KEY / ID
</span>
<span class="xyz">ABCD EFGH</span>
<span class="summary">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</span>
</div>
<div class="container">
<span class="id">
KEY / ID
</span>
<span class="xyz">ABCD EFGH</span>
<span class="summary">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</span>
</div>
</div>
Fiddle

#services div has content but appears as empty div

My #services div has content wrapped inside, but when I wanna give display it's borders or give it a background, it appears as an empty div. What's the trick here? Looks like it works well in the snippet, but here is the way it appears: http://laszlovaszi.com/yoursite/ .Thanks in advance!
#services {
border:1px solid red;
margin-top:50px;
background-color:#f1eee9;
}
#services p {
margin-top:25px;
}
.separator2 {
width: 100%;
margin: 20px auto 15px;
position: relative;
height: 1px;
background-color:#d3d3d3;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div id="services">
<div class="col-sm-8 col-sm-offset-2 text-center">
<div class="row">
<h1>Our Team</h1>
<div class="separator2"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<div class="col-md-4 service">
<div class="img-responsive">
<img src="photos/service.jpeg" alt="Service">
</div>
<div class="service_description">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="col-md-4 service">
<div class="img-responsive">
<img src="photos/service.jpeg" alt="Service">
</div>
<div class="service_description">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="col-md-4 service">
<div class="img-responsive">
<img src="photos/service.jpeg" alt="Service">
</div>
<div class="service_description">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</row>
</div>
</div>
After correcting your markup (amending the </row> tag to a </div>), I noticed your wrapping #services div appears to be collapsing due to its floated children. Add a clearfix class to it as below:
#services {
border:1px solid red;
margin-top:50px;
background-color:#f1eee9;
}
#services p {
margin-top:25px;
}
.separator2 {
width: 100%;
margin: 20px auto 15px;
position: relative;
height: 1px;
background-color:#d3d3d3;
}
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
.cf {
*zoom: 1;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div id="services" class="cf">
<div class="col-sm-8 col-sm-offset-2 text-center">
<div class="row">
<h1>Our Team</h1>
<div class="separator2"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<div class="col-md-4 service">
<div class="img-responsive">
<img src="photos/service.jpeg" alt="Service">
</div>
<div class="service_description">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="col-md-4 service">
<div class="img-responsive">
<img src="photos/service.jpeg" alt="Service">
</div>
<div class="service_description">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
<div class="col-md-4 service">
<div class="img-responsive">
<img src="photos/service.jpeg" alt="Service">
</div>
<div class="service_description">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</div>
</div>
</div>
You'll notice now, the #services div has its height reinstated (before it just had a 2px height due to the border).
Clearfix micro hack: http://nicolasgallagher.com/micro-clearfix-hack/
More info: What is a clearfix?
You need to use float property to achieve so
#services {
border:1px solid red;
margin-top:50px;
background-color:#f1eee9;
float:left;
width:100%:
}
Also you can add width attribute if you want to.