3 Box grid not equal width as they change depending on text - html

I have a small bit of HTML in a word press post body which I have (want) 3 equal width boxes, except the third box is smaller if i have less text (or more in another box) and i cant figure out how to keep the sizes static.
I have tried adding CSS containers, adding physical widths but nothing changes.
Current Code:
<div>
<div class="page-content">
<div class="grid grid--thirds">
<div class="grid__item" data-match-height="login-block-container" display:block width: 33%;>
<a class="login_link" href="https://www.google.com">
<div class="login-block">
<h5 class="login-block__title">B1HEADERTEXT</h5>
<p>B1BODYTEXT</p>
</div>
</a>
</div>
<div class="grid__item" data-match-height="login-block-container" display:block width: 33%;>
<a class="login_link" href="https://www.google.com">
<div class="login-block">
<h5 class="login-block__title">B2HEADERTEXT</h5>
<p>B2BODYTEXT</p>
</div>
</a>
</div>
<div class="grid__item" data-match-height="login-block-container" display:block width: 33%;>
<a class="login_link" href="https://www.google.com">
<div class="login-block">
<h5 class="login-block__title">B3HEADERTEXT</h5>
<p>B3BPDYTEXT</p>
</div>
</a>
</div>
</div>
</div>
</div>
How it looks:
With differing amounts of text:
<div>
<div class="page-content">
<div class="grid grid--thirds">
<div class="grid__item" data-match-height="login-block-container" display:block width: 33%;>
<a class="login_link" href="https://www.google.com">
<div class="login-block">
<h5 class="login-block__title">B1HEADERTEXT</h5>
<p>B1BODYTEXT</p>
</div>
</a>
</div>
<div class="grid__item" data-match-height="login-block-container" display:block width: 33%;>
<a class="login_link" href="https://www.google.com">
<div class="login-block">
<h5 class="login-block__title">B2HEADERTEXT</h5>
<p>B2BODYTEXT</p>
</div>
</a>
</div>
<div class="grid__item" data-match-height="login-block-container" display:block width: 33%;>
<a class="login_link" href="https://www.google.com">
<div class="login-block">
<h5 class="login-block__title">B3HEAD</h5>
<p>B3BPDYTEXT</p>
</div>
</a>
</div>
</div>
</div>
</div>
How that looks:

Judging by the image you've posted, it seems as if the parent or parent container is behaving like a flex or grid or something similar.
If you don't want the content of each box to effect the width of any box, you can do this by applying the following code to each box.
.box {
width: calc(100% / 3);
word-wrap: break-word;
}

Related

How to dynamically display cards in a grid

I am designing the UI for a web app which will dynamically display data from my database in form of cards and will be arranged in a grid. For testing purposes I have put two cards , one after the other , however, only the first one is being displayed.
How can I get them to be displayed in a 3 column row after which if there are more than 3, they overflow to the next row dynamically?
<div class="container_grid">
<div class="product-card" style="margin: 1rem">
<div class="product-front">
<div class="shadow"></div>
<img src="https://veenaazmanov.com/wp-content/uploads/2019/08/Chocolate-Birthday-Cake5-500x500.jpg" alt="" />
<div class="image_overlay"></div>
<div class="view-details">View details</div>
<div class="stats">
<div class="stats-container">
<span class="product_price">Ksh.500</span>
<span class="product_name">Chocolate Cake</span>
<p>Tasty cake</p>
<div class="product-options">
<strong>Available in</strong>
<span>1kg, 2kg, 3kg, 4kg, 5kg</span>
<button class="btn">Add To Cart</button>
<!-- <div class="cart_btn"><p>Add to Cart</p></div> -->
</div>
</div>
</div>
</div>
</div>
<div class="product-card" style="margin: 1rem">
<div class="product-front">
<div class="shadow"></div>
<img src="https://veenaazmanov.com/wp-content/uploads/2019/08/Chocolate-Birthday-Cake5-500x500.jpg" alt="" />
<div class="image_overlay"></div>
<div class="view-details">View details</div>
<div class="stats">
<div class="stats-container">
<span class="product_price">Ksh.500</span>
<span class="product_name">Chocolate Cake</span>
<p>Tasty cake</p>
<div class="product-options">
<strong>Available in</strong>
<span>1kg, 2kg, 3kg, 4kg, 5kg</span>
<button class="btn">Add To Cart</button>
</div>
</div>
</div>
</div>
</div>
</div>
Link to the full JFiddle: https://jsfiddle.net/5yoerguh/3/
What am I doing wrong?
Both are being displayed if you check the console both div class='product-card' is there.
The problem is in the css your class .propduct-card is displayed with position:absolute;
.product-card {
width: 20rem;
max-width: 95%;
width: 325px;
height: 490px;
--> take this out /* position: absolute; */
overflow: hidden;
}
Now you will see both items

Center Container

I'm working on making front end design for someone but I don't have access to the css file or classes, so I can't see what's causing the container align left.
I'm looking to center the container on screen. What would be best approach? I tried wrapping div with text-align: center !important; that didn't work.
<div class="portlet-content">
<div class="portlet-content-container">
<div class="portlet-body">
<div>
<div class="container">
<div class="biography-view">
<div class="biography-item col-md-6">
<div style="border-style:none">
<div class="biographyimage" style="background-image:url(http://www.math.uni-frankfurt.de/~person/_4170854.jpg);"> </div>
<div class="caption biography-profile">
<div class="biography-profile-content">
<h3 class="full-name">Name</h3>
<p class="person-title">Company Name</p>
<p class="person-title"><strong>Person Title</strong></p>
<div class="person-biography">Biography</div>
<div class="person-biography collapse" id="readmore">More Person Info</div>
<a class="read_more" data-target="#readmore" data-toggle="collapse">Read More</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
In a CSS block for the container, you can center it as follows:
margin-left: auto;
margin-right: auto;
Use inline styles <div class="portlet-content" style="text-align:center;"> or somthing yours based on css specificity mozila MDN

Bootstrap css Aligns the text to the center by the text length of the other div

I want to use css, bootstrap to align the first line align left, and the second line will center on the text length of the first line.
I tried many ways but not.
code follow
<div class="col-md-6">
<a href="/" style="text-decoration:none">
<div class="col-md-12 row-eq-height" style="padding:0;">
<div class="col-md-2" style="padding:0">
<img src="/Content/images/logo.png" class="img-responsive" alt="">
</div>
<div class="col-md-10 tex-center" style="padding-right:0;">
<div style="padding:0">
<div class="line1-bold">THIS IS THE FIRST LONG HEADLINE</div>
<div class="line2">THIS IS THE SECOND HEADLINE</div>
</div>
</div>
</div>
</a>
</div>
Please check this..
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="col-md-6">
<a href="/" style="text-decoration:none">
<div class="col-md-12 row-eq-height" style="padding:0;">
<div class="col-xs-2" style="padding:0">
<img src="https://www.tenforums.com/attachments/browsers-email/18558d1485951187t-microsoft-edge-logo-microsoft-edge-100582336-large.png" class="img-responsive" style="width:100px" alt="">
</div>
<div class="" style="float:left;">
<div class="line1-bold" style="color:#b63957; font-size:18px;">THIS IS THE FIRST LONG HEADLINE</div>
<div class="line2" style="color:#b63957; font-size:16px; text-align:center;">THIS IS THE SECOND HEADLINE</div>
</div>
</div>
</a>
</div>
Try adding the class text-center to your divs.
Here is a working pen.
Something like this?
I don't know about your task, but I deleted some tags.
CSS
.img-responsive {
width: 100px;
float: left;
}
span {
display: block;
}
HTML
<div class="col-md-6">
<a href="/" style="text-decoration:none">
<div class="col-md-12 row-eq-height" style="padding:0;">
<img src="https://www.tenforums.com/attachments/browsers-email/18558d1485951187t-microsoft-edge-logo-microsoft-edge-100582336-large.png" class="img-responsive" alt="">
<span class="text-left">THIS IS THE FIRST LONG HEADLINE</span>
<span class="text-center">THIS IS THE SECOND HEADLINE</span>
</div>
</a>
</div>
Reference Link

How to make same height of all responsive images in a row

The first image of the row doesn't have the same height as the other ones. I am using Bootstrap .img-responsive.
HTML
<div class="row">
<div class="down-content">
<div class="haber">
<!--HABER 1-->
<div class="col-sm-3">
<div id="haber1">
<div id="haberimg1">
<img class="img-responsive" src="http://www.avukatwebsite.net/public/_uploads/photos/temalar/avukat-web-site-tema-1.jpg" >
</div>
<div id="haberyazi1">
<h3>Kanser Affetmedi...</h3>
<p>Sanssiz genc Kanser yüzünden öldü...</p>
<button type="button" class="btn">Devamini Oku...</button>
</div>
</div>
</div>
<!--HABER 2-->
<div class="col-sm-3">
<div id="haber2">
<div id="haberimg2">
<img class="img-responsive" src="http://medicare.bold-themes.com/clinic/wp-content/uploads/sites/2/2015/12/shutterstock_288977717-1200x800.jpg" >
</div>
<div id="haberyazi2">
<h3>Sizofreni Salgini</h3>
<p>Türkiyede ki Sizofren sayisinda artis görüldü...</p>
<button type="button" class="btn">Devamini Oku...</button>
</div>
</div>
</div>
/* we deleted the other parts because of mostly code problem */
</div>
<!--HABER BÖLÜMÜ BITIS-->
</div>
</div>
Bootstrap CSS
.img-responsive,
.thumbnail > img,
.thumbnail a > img,
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
display: block;
max-width: 100%;
height: auto;
}
This is the issue:
There are a number of solutions. Here is a couple of similar solutions. First you would need to create a div that scales responsively. This can be achieved with:
.img-wrap {
height:0;
// adjust the padding to change the aspect ratio of the div
padding-bottom:60%;
}
you can then either add a background image to the .image-wrap element with background-size:cover. Or you could place an image inside .image-wrap and then position:absolute; it inside .image-wrap and add object-fit: cover; width: 100%; height: 100%;.
Answer 1:
You have to set a fixed height to the img parent div and then set height:100% to the img Check below Snippet:
.haberImg {
height: 75px;
}
.haberImg img {
height: 100%;
width: 100%;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row">
<div class="down-content">
<div class="haber">
<!--HABER 1-->
<div class="col-xs-3">
<div id="haber1">
<div id="haberimg1" class="haberImg">
<img class="img-responsive" src="http://www.avukatwebsite.net/public/_uploads/photos/temalar/avukat-web-site-tema-1.jpg"></div>
<div id="haberyazi1">
<h3>Kanser Affetmedi...</h3>
<p>Sanssiz genc Kanser yüzünden öldü...</p>
<button type="button" class="btn">Devamini Oku...</button>
</div>
</div>
</div>
<!--HABER 2-->
<div class="col-xs-3">
<div id="haber2">
<div id="haberimg2" class="haberImg">
<img class="img-responsive" src="http://medicare.bold-themes.com/clinic/wp-content/uploads/sites/2/2015/12/shutterstock_288977717-1200x800.jpg"></div>
<div id="haberyazi2">
<h3>Sizofreni Salgini</h3>
<p>Türkiyede ki Sizofren sayisinda artis görüldü...</p>
<button type="button" class="btn">Devamini Oku...</button>
</div>
</div>
</div>
</div>
</div>
Answer 2:
You have to set a fixed height to the img parent div as the smallest img height and then add overflow:hidden. Check below Snippet:
.haberImg {
height: 80px;
overflow:hidden;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row">
<div class="down-content">
<div class="haber">
<!--HABER 1-->
<div class="col-xs-3">
<div id="haber1">
<div id="haberimg1" class="haberImg">
<img class="img-responsive" src="http://www.avukatwebsite.net/public/_uploads/photos/temalar/avukat-web-site-tema-1.jpg"></div>
<div id="haberyazi1">
<h3>Kanser Affetmedi...</h3>
<p>Sanssiz genc Kanser yüzünden öldü...</p>
<button type="button" class="btn">Devamini Oku...</button>
</div>
</div>
</div>
<!--HABER 2-->
<div class="col-xs-3">
<div id="haber2">
<div id="haberimg2" class="haberImg">
<img class="img-responsive" src="http://medicare.bold-themes.com/clinic/wp-content/uploads/sites/2/2015/12/shutterstock_288977717-1200x800.jpg"></div>
<div id="haberyazi2">
<h3>Sizofreni Salgini</h3>
<p>Türkiyede ki Sizofren sayisinda artis görüldü...</p>
<button type="button" class="btn">Devamini Oku...</button>
</div>
</div>
</div>
</div>
</div>
A simple way is to use images that have the same width and the same height! (You avoid a lot of problems and there is no need to fix something with CSS)
HTML
<div class="row">
<div class="col-sm-3">
<img src="http://placehold.it/400x300" alt="" class="img-responsive">
<h3>Heading</h3>
<p>Text</p>
<button class="btn">More</button>
</div>
<div class="col-sm-3">
<img src="http://placehold.it/400x300" alt="" class="img-responsive">
<h3>Heading</h3>
<p>Text</p>
<button class="btn">More</button>
</div>
<div class="col-sm-3">
<img src="http://placehold.it/400x300" alt="" class="img-responsive">
<h3>Heading</h3>
<p>Text</p>
<button class="btn">More</button>
</div>
<div class="col-sm-3">
<img src="http://placehold.it/400x300" alt="" class="img-responsive">
<h3>Heading</h3>
<p>Text</p>
<button class="btn">More</button>
</div>
</div>
Just give your images same class and add height.
Trick: avoid of giving height with pixels because getting issue in small screen instead give height with rem or
percentage
It's very easy actually, use display grid and grid-auto-columns: 1fr.

Can not get the element to be at the bottom of the page

Basically the idea is that I have a picture galery and at the bottom there should be a load more bar. I have tried a lot of different options of using the bottom tag but somehow the element always stays right after the div that is above him. What should I change to make it work?
.portfolio_bottom {
padding: 2em 0;
position: absolute;
bottom: 0px;
}
<body>
<div class="portfolio s1" id="portfolio">
<div class="portfolio_box">
<div class="col_1_of_4 span_1_of_4">
<a href="#" class="b-link-stripe b-animate-go thickbox">
<img src="images/p1.jpg" class="img-responsive" alt=""/>
<div class="b-wrapper">
<h2 class="b-animate b-from-left b-delay03 ">
<img src="images/p_logo.png" class="img-responsive" alt=""/>
<span>Cerkve</span>
<button>Odpri galerijo</button>
<label> &#x1f4c5 10.6.2016 </label>
</h2>
</div>
</a>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div class="portfolio_bottom">
<a class="btn3" href="#"><span>Loadmore</span></a>
</div>
<script src="js/bootstrap.min.js"></script>
</body>
Assign position:relative to the parent element.
#portfolio {position:relative;}