Make text always stick at bottom of image for responsive site - html

I have a small div under each image that I need to be exactly at the bottom of the image also when my site is viewed on small devices. My whole site is in Bootstrap-3 already, but now my current code shows the small div called DATA half way over the image when viewed on smaller devices.
Two issues:
1 - How to make the div (data) have the responsive width of the responsive image always?
2 - How to make sure the div (data) sticks at the bottom of the image always for different device dimensions?
I was messing around with top:400px but I cannot get it right, and width should actually always be 100% namely the width of the image but still my div sticks out way too much...
.image {
max-width: 100%;
max-height: 100%;
margin: 0;
display: block;
padding: 0px;
}
.data {
font-size: 11px;
font-family: 'Source Sans Pro',sans-serif;
font-style: normal;
color: #FFF;
font-weight: 700;
background-color: #000;
opacity: 0.7;
padding: 0 10px 0 10px;
border-bottom: 0px solid #FFF;
z-index: 3;
display: block;
position: absolute;
opacity: 0.7;
top: 400px;
left: 0;
min-width: 100%;
}
<div class="block">
<div class="item">
<div class="image"><img alt="" src="http://lorempixel.com/400/400" /></div>
<div class="tag">
TAG
</div>
<div class="title">
title
</div>
<div class="data">
<div class="date">
01012001
<div class="author">
Author
</div>
</div>
</div>
</div>
</div>

I hope i understand u right... so, your issue is:
Div .data must be always 100% width over the image?
Div .data must be always at bottom on the imate?
So check that:
.image {
position: relative;
display: inline-block; /* This can be inline too */
margin: 0 auto;
padding: 0px;
}
.image .data {
padding: 0 10px;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
box-sizing: border-box;
background-color: rgba(0, 0, 0, 0.7);
font-size: 11px;
font-family: 'Source Sans Pro',sans-serif;
font-style: normal;
font-weight: 700;
color: #FFF;
}
<div class="block">
<div class="item">
<div class="image">
<img alt="" src="http://lorempixel.com/400/400" />
<div class="data">
<div class="date">
01012001
<div class="author">
Author
</div>
</div>
</div>
</div>
<div class="tag">
TAG
</div>
<div class="title">
title
</div>
</div>
</div>
Some advices- try to group css styles. Use better selectors. Try to use all HTML 5 tags- for example, image can be wrapped with figure tag and the .data element- can be just figurecaption.
Good luck!

Related

Why scrollable cards height are not increasing according to his content

I designed the scrollable cards. The cards are only for mobile screens. The current issue is that more data gets encapsulated inside the scrollable wrapper as the content grows. No matter how long the content is, I want the div's height to increase. Is there a fix for this design that makes the card's height rise in proportion to its contents?
The read more functionality is implemented, but I didn't add it to the snippet. By default, all the content will be the same. But on read more, the content can vary. So, I want the design to be fixed so read more content does not affect the card.
By default:
On clicking read more/content increases:
.scrolling-wrapper {
-webkit-overflow-scrolling: touch;
height: 474px;
width: 100%;
padding-inline: 40px;
position: relative;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
z-index: 0;
padding-top: 150px;
visibility: visible;
}
.scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.card {
width: 100%;
flex: 0 0 auto;
background-color: green;
border-radius: 20px;
position: relative;
margin-inline-end: 10px;
}
.our-member-owner-card-image {
position: absolute;
top: -66px;
z-index: 10;
left: 29%;
}
.card-content {
position: absolute;
padding-top: 38px;
}
.member-detail {
padding-top: 55px;
line-height: 1.7;
}
.member-detail h3 {
text-align: center;
color: #263244;
font-weight: 700;
font-family: "Lato";
}
.member-detail p {
text-align: center;
color: #737c89;
}
.member-description {
padding-inline: 20px;
color: #263244;
line-height: 1.6;
padding-top: 9px;
font-weight: 500;
font-size: 16px;
font-style: normal;
font-weight: 500;
}
.member-description .read-more {
color: #eb644c;
text-decoration: underline;
cursor: pointer;
}
<div class="scrolling-wrapper">
<div class="card">
<div class="our-member-owner-card-image">
<img width="140px" src="https://images.unsplash.com/photo-1579279219378-731a5c4f4d16?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8bXIlMjBiZWFufGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=500&q=60" />
</div>
<div class="card-content">
<div class="member-detail">
<h3 id="mobile-member-name">Mr bean</h3>
<p id="mobile-member-designation">Actor</p>
</div>
<div class="member-description">
<span id="mobile-member-description">
Mr Bean has extensive work experience during his career of more than 25 years in the film industry.
</span>
<span id="mobile-more" >Some dummy text </span>
<span id="mobile-member-description-readmore" class="readMoreLink read-more" >Read less</span>
</div>
</div>
</div>
<div class="card">
<div class="our-member-owner-card-image">
<img width="140px" src="https://images.unsplash.com/photo-1579279219378-731a5c4f4d16?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8bXIlMjBiZWFufGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=500&q=60" />
</div>
<div class="card-image-shadow"></div>
<div class="card-content">
<div class="member-detail">
<h3 id="mobile-member2-name">Mr bean</h3>
<p id="mobile-member2-designation">Actor</p>
</div>
<div class="member-description">
<span id="mobile-member2-description">
Mr Bean has extensive work experience during his
career of more than 25 years in the film industry
</span>
<span id="mobile-more2" >Some dummy text </span>
<span id="mobile-member2-description-readmore" class="readMoreLink read-more" " >Read less</span
>
</div>
</div>
</div>
</div>
As I understood your question, your issue is that the content is pushing out because you have defined an absolute height for the container. Let the content determine the height dynamically. Instead of using height and max-height, try using min-height. That way, if the content needs more space, it can grow.
So removing this should make the cards grow based on the size of the content
.scrolling-wrapper {
height: 474px;
}
I think adding
min-height: fit-content
to .scrolling-wrapper will do what you want

Why doesn't the position work properly in the section

I have a section part on the website where I want four products being displayed in the middle, right and left arrows on both sides of the screen and a title in the middle above the displayed products, I think I have all of the HTML and CSS good but the position isn't working properly, can someone have a look and help me feature it out?img of the sections I am talking about
ps: the background color doesn't feel the space that the items and buttons are in, why does it happens too?
edit: this is a pic of how i wish it would look
HTML:
<section class="one">
<div><span class="title">New products</span></div>
<br>
<button class="left">
<span class="Lmain"></span>
<span class="Lside"></span>
</button>
<div class="items">
<div class="item">
<a href="">
<img class="itemImg" src="../Images/Image1.png" alt="Picture of the product">
</a>
<div><span class="desc">Description about that specific item that is being showen to you above this text
right here</span></div>
</div>
<div class="item">
<a href="">
<img class="itemImg" src="../Images/Image2.png" alt="Picture of the product">
</a>
<div><span class="desc">Description about that specific item that is being showen to you above this text
right here</span></div>
</div>
<div class="item">
<a href="">
<img class="itemImg" src="../Images/Image3.png" alt="Picture of the product">
</a>
<div><span class="desc">Description about that specific item that is being showen to you above this text
right here</span></div>
</div>
<div class="item">
<a href="">
<img class="itemImg" src="../Images/Image4.png" alt="Picture of the product">
</a>
<div><span class="desc">Description about that specific item that is being showen to you above this text
right here</span></div>
</div>
</div>
<button class="right">
<span class="Rmain"></span>
<span class="Rside"></span>
</button>
</section>
CSS:
.title {
text-align: center;
position: absolute;
margin: auto;
border: 1px solid goldenrod;
font-size: 40px;
}
.one {
background-color: hotpink;
position: relative;
}
.two {
background-color: rgb(255, 0, 128);
}
/*items appearance*/
.items {
position: relative;
margin: auto;
}
.item {
border: 1px solid rgb(255, 170, 0);
float: left;
position: absolute;
top: 0px;
margin: 0px 8px;
left: 12%;
width: 350px;
height: auto;
}
.itemImg {
width: 100%;
height: auto;
}
/*end of item appearance*/
.right {
right: 0px;
top: 0px;
position: absolute;
}
.left {
left: 0px;
top: 0px;
position: absolute;
}
Utilize flexbox to make this layout easy:
body {
margin: 0;
background: #1a1a1a;
color: #fff;
font-family: sans-serif;
}
h1#title {
padding: 1rem;
text-align: center;
}
main {
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
}
#products {
display: flex;
justify-content: center;
align-items: flex-start;
margin: 0;
}
.product {
padding: 2rem 1rem;
background: #fff;
color: black;
margin: .5rem;
}
<body>
<h1 id="title">Items</h1>
<main>
<div class="arrow" id="arrow-left">←</div>
<div id="products">
<div class="product">
Product
</div>
<div class="product">
Product
</div>
<div class="product">
Product
</div>
<div class="product">
Product
</div>
</div>
<div class="arrow" id="arrow-right">→</div>
</main>
</body>
Here a list of problem I see:
the .title element is position:absolute, so it doesn't fill any space and other elements will position weirdly. Solution: remove position: absolute
the .title is a <span> element witch is an inline-element who doesn't behave like a block element (<div>, <p>, <h1>, etc.), so the text-align: center doesn't take effect. Solution: remove the span and give the .title class to the parent <div>
the left and right buttons should be wrapped in a <div> with position:relative
Here is a jsfiddle with the fixed code.
I didn't fix the image positioning because i think those will be positioned by js, anyhow it dipends by the images dimensions and is a very weak method. So I strongly suggest using flexbox that is widely supported by browsers.
You can follow the #yerme example or this guide on flexbox.

Putting Text over Image while being responsive

How do i place text over image div in certain position while keeping it responsive(doesn't move from that spot on smaller devices or bigger)
Problem im getting is that most of the content wont fit like i want it or wont even stick to image in smaller devices, so i need solution on how to solve this one,placing 3 text divs on image div without using method of making background image, i need it to work with tag
Bootstrap v4
i tried this:
CODEPEN
<div class="slider">
<div class="cover-image">
<div class="image-link">
<div class="image-date">
<p>08.10.2017</p>
</div>
<div class="image-text">
<div class="img-test"><h2>Gradjevina koja se gradi duze od egipatskih piramida</h2></div>
</div>
Eskterijer
</div>
<img class="img-fluid" src="#asset('/images/slider-1.png')">
</div>
</div>
and CSS:
.cover-image {
position: relative;
}
.slider .image-link {
position: absolute;
bottom: 20px;
left: 10px;
width: 100%;
color: white;
}
.img-test {
font-family: Oswald;
font-size: 40px;
font-weight: 600;
position: absolute;
bottom: 50px;
left: 10px;
color: white;
text-transform: none;
}
.slider .image-date {
position: absolute;
bottom: 150px;
left: 10px;
color: white;
border-bottom: 1px solid white;
margin-bottom: 0;
}
<div class="slider">
<div class="cover-image">
<div class="image-link">
<div class="image-date">
<p>08.10.2017</p>
</div>
<div class="image-text">
<div class="img-test">
<h2>Gradjevina koja se gradi duze od egipatskih piramida</h2>
</div>
</div>
Eskterijer
</div>
<img class="img-fluid" src="http://vietlongtravel.com/wp-content/uploads/2017/05/151548909_high-770x530.jpg">
</div>
</div>

Can any tell me what I am doing wrong?

I am trying to position a div to the left of the screen and I am also trying to make it work on any screen resolution and browser.
Here's my code below:-
#Biography {
background: #ffffff ;
text-align: center ;
text-transform: uppercase ;
color: #fff ;
padding: 5em 0;
width: 100%;
font-family: 'Conv_Lato-Regular',Sans-Serif;
margin: 0;
}
#info {
left: -10px;
float: left;
top: -80px;
position: relative;
color: #000;
}
<div id="Biography">
<div class="container">
<div class="tittle">
</div>
<div id="info">
<div class="col-md-8">
<div class=" wow bounceInDown" data-wow-delay="0.5s">
<div class="view view-fifth" style="height: 20%">
<img src="images/Dan.jpeg" alt="" style="height:80%; width:100%">
<h4> NAME</h4>
<h5> sean</h5>
<h4> OCCUPATION</h4>
<h5> Computer Programmer,Software Developer,Student</h5>
</div>
</div>
</div>
</div>
The problem is that the #info div is not fully to the left. I don't know what I am doing wrong.
You need to use 'position:absolute' instead of 'position:relative' to be located fully to the left in this case.
#info {
position: absolute;
left: 0px;
top: 0px;
color: #000;
}

Stacking Multiple Divs From Bottom to Top

I am trying to align multiple divs (buttonNav) to the bottom of a container div (lowerNav). I have read every question on here regarding this and tried the CSS and it does not seem to work. I tried this one: Stacking Divs from Bottom to Top amoung others, hoping someone can help.
Here is my html, I have 5 of the lowerNav containers each with multiple buttonNavs that I want to align to the bottom of the lowerNav here is the code from one, they are all set up the same way:
<div class="lowerNav">
<img src="image/contact-us.gif" width="126" height="27" alt=""/>
<p>Ready to get more information or contact us directly?</p>
<div class="buttonNav">
<p>Order Literature</p>
</div>
<div class="buttonNav">
<p>Downloads</p>
</div>
<div class="buttonNav">
<p>Email Sign-Up</p>
</div>
<div class="buttonNav">
<p>Meet Your Rep</p>
</div>
<div class="buttonNav">
<p>Ask a Question</p>
</div>
</div>
Here is my CSS:
.lowerNav {
width: 160px;
height: 325px;
background-color: #e3dfd7;
border: 3px solid #383431;
float: left;
margin: 15px 8px 0px 8px;
text-align: left;
display: table-cell;
vertical-align: bottom;
}
.lowerNav p {
padding: 5px 12px 12px 12px;
}
.lowerNav img {
padding-top: 12px;
}
.buttonNav {
background:url(image/button-lowerNav.jpg);
width: 160px;
height: 45px;
display: inline-block;
}
.buttonNav p {
text-align:center;
padding-top: 14px;
}
.buttonNav a {
color: #fff;
font-size: 13px;
text-decoration:none;
font-weight:700;
}
.buttonNav a:hover {
color: #fff;
font-size: 13px;
text-decoration:underline;
font-weight:700;
}
Since the container (.lowerNav) has a fixed height and you know the size of its content this is quite easy to do with absolute positioning.
HTML:
<div class="outer">
Hello up here!
<ul class="inner">
<li>Hello</li>
<li>down</li>
<li>there!</li>
</ul>
</div>
CSS:
.outer {
position: relative;
height: 200px;
}
.inner {
position: absolute;
bottom: 0;
}
Check this CodePen for a live example of this code: http://codepen.io/EvilOatmeal/pen/fCzIv