I have a grid layout of cards. When I upload photos to a product card, there are several times that the entire format of the card is damaged. That is, no labels, the name, the description of the product and some other things are not visible.
I am attaching 2 screenshots (one without and one with photos)
.bg-color {
background-color: #eee;
padding: 60px 0;
}
.containers {
width: 90%;
margin: 0 auto;
}
.title {
margin-bottom: 50px;
padding-bottom: 40px;
text-align: center;
position: relative;
}
.title::before {
content: '';
width: 200px;
height: 3px;
background-color: #dbdbdb;
position: absolute;
bottom: 15%;
left: 50%;
transform: translateX(-50%);
}
.title::after {
content: '\f005';
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
color: #dbdbdb;
width: 50px;
height: 20px;
text-align: center;
line-height: 20px;
position: absolute;
bottom: 10%;
left: 10%;
/* background-color: #eee;
*/
transform: translateX(-50%);
font-size: 16px;
}
.title p {
color: #999;
font-style: italic;
font-weight: 700;
margin: 0;
}
.title h1 {
font-size: 44px;
color: #131313;
font-weight: 900;
text-transform: capitalize;
}
.title h1 span {
color: #fa0;
}
.my-card {
transition: all .2s ease-in-out;
border-radius: 3px;
}
.card-main {
position: relative;
}
.price {
position: absolute;
background: #fa0;
font-weight: 700;
color: #ffff;
text-align: center;
display: block;
text-transform: uppercase;
height: 30px;
width: 50px;
border-radius: 0 15px 15px 0;
line-height: 30px;
font-style: italic;
left: -9px;
top: 30px;
}
.price::after {
border-top: 6px solid #c80;
content: '';
position: absolute;
bottom: -6px;
left: 0;
border-left: 8px solid transparent;
border-right: 0px solid transparent;
}
.label {
position: absolute;
top: 10px;
/* bottom: 104px;
*/
left: -9px;
font-size: 10px;
font-weight: 400;
text-transform: uppercase;
z-index: 2;
line-height: 100%;
color: #ffff;
border-radius: 3px;
padding: 5px 8px;
}
.label-green {
background: #5cb85c;
}
.label2 {
position: absolute;
top: 10px;
/* bottom: 104px;
*/
right: -9px;
font-size: 10px;
font-weight: 400;
text-transform: uppercase;
z-index: 2;
line-height: 100%;
color: #ffff;
border-radius: 3px;
padding: 5px 8px;
}
.label-red {
background: #C5312D;
}
.image img {
width: 100%;
height: 100%;
position: center;
}
.cart-line {
height: 2px;
background: #f1f1f1;
}
.cart-item {
text-align: center;
line-height: 45px;
background: #fa0;
/* background: rgb(199, 136, 53);
*/
transition: all 0.4s ease-in-out;
position: relative;
top: -30px;
}
.cart-item ul {
padding: 0;
margin: 0;
}
.cart-item ul li {
display: inline-block;
list-style-type: none;
position: relative;
font-size: 25px;
}
.cart-item ul li::after {
content: '';
width: 1px;
height: 18px;
background: rgba(255, 255, 255, .15);
position: absolute;
left: -2px;
top: 10px;
}
.my-card:hover .cart-item {
opacity: 1;
top: 0;
}
.item-container {
position: absolute;
right: -40px;
top: 10px;
z-index: 4;
transition: 0.6s;
opacity: 0;
}
.p {
border: 1px solid rgb(233, 233, 233);
border-radius: 2px;
height: 40px;
width: 40px;
cursor: pointer;
}
.p img {
width: 100%;
height: 100%;
opacity: 0.8;
}
.p img:hover {
opacity: 1;
}
.my-card:hover .item-container {
opacity: 1;
right: 10px;
}
.content {
padding: 16px 0;
text-align: center;
}
.content mat-card-title {
font-size: 16px;
color: #555;
font-weight: 700;
text-transform: capitalize;
transition: all .3s;
}
.content mat-card-title:hover {
color: #fa0;
text-decoration: none;
}
.content p {
margin-bottom: 0;
}
.content .description {
font-size: 15px;
color: #fa0;
font-weight: 500;
font-style: italic;
margin-right: 6px;
}
<section class="bg-color">
<div class="containers">
<mat-grid-list [cols]="breakpoint" rowHeight="500px" (window:resize)="onResize($event)">
<mat-grid-tile *ngFor="let item of pagedList">
<div>
<mat-card class="my-card">
<div class="card-main">
<div *ngIf="item.buy_price != 0">
<div class="label label-green">Buy NOW</div>
<div class="price">{{item.buy_price | currency:'EUR':true}}</div>
</div>
<div *ngIf="item.seller == username">
<div class="label2 label-red">My item</div>
</div>
<!-- Small images -->
<div class="item-container">
<div *ngIf="item.images.length!==0">
<div *ngFor="let image of item.images">
<div class="p"><img [src]="'data:image/jpeg;base64,' + image.imageByte" alt="item"> </div>
</div>
</div>
</div>
<!-- 1st image -->
<div class="image">
<div *ngIf="item.images.length==0">
<img src="/assets/images/no_image_found.jpg" alt="image">
</div>
<div *ngIf="item.images.length!=0">
<img [src]="'data:image/jpeg;base64,' + item.images[0].imageByte" alt="image">
</div>
</div>
<div class="cart-line"></div>
<div class="cart-item">
<ul>
<li><a routerLink="/item-detail/{{item.id}}"><i class="bi-basket"></i></a></li>
</ul>
</div>
</div>
<div class="content">
<mat-card-title>{{item.name.length>34?item.name.substring(0,30)+ "...":item.name}}</mat-card-title>
<p><span class="description">{{item.description.length>34?item.description.substring(0,30)+ "...":item.description}}</span></p>
</div>
</mat-card>
</div>
</mat-grid-tile>
</mat-grid-list>
</div>
</section>
Related
I am trying to create a progress bar with multiple money til current date based on this UX sample
So far, I am able to display the first circle. Here's an output output of my code:
HTML:
<div class={`col-md-12`}>
<h3 class="line-bottom mt-0">Money Earned to Date</h3>
<div class="row">
<div class="col-md-6">
<div class="progress">
<div class="progress-bar" style="width: 12%; background: #ed687c;">
<span class="progress-icon fa fa-dollar-sign" style="color: #707070; border-color: #707070;"></span>
<div class="progress-value">$100</div>
</div>
</div>
</div>
</div>
</div>
CSS
.progressbar-title {
font-size: 14px;
color: #848484;
text-transform: capitalize;
}
.progress {
height: 30px;
overflow: visible;
background: #f4bc25;
margin-top: 25px;
margin-bottom: 40px;
border-radius: 20px;
border: 1px solid #707070;
}
.progress .progress-bar {
position: relative;
}
.progress .progress-icon {
width: 55px;
height: 53px;
line-height: 47px;
border-radius: 50%;
font-size: 20px;
position: absolute;
top: -14px;
right: 0;
padding: 0 19px;
background: #fff;
border-width: 3px;
border-style: solid;
color: #707070;
}
.progress-value {
font-size: 15px;
color: #000;
position: absolute;
top: 45px;
right: 11px;
}
Can someone please help me finish the remaining parts on the UX?
if you want to make more circles dynamically you have to make it with Javacript but if you want it static (with only 5 circles) then here you go :
.row,.progress{ position: relative;width: 100%;}
.progress-bar{position:relative;background: #f6ba2b;height: 24px; border-radius:36px}
.progress-bar > .offCircle{
position:absolute;width:100%;
height:100%;
/* background:red; */
}
.progress:after,
.progress-bar:before,
.progress-bar:after,
.progress-bar > .offCircle:before,
.progress-bar > .offCircle:after
{
position:absolute;
color: #707070;
top: 0;
width:33px;
height: 33px;
background:#fff;
margin-top: -7.5px;
margin-top: -6.5px;
border-radius:36px;
border: 2px solid #707070;
text-shadow: 0 0 0px black;
line-height: 2.2;
text-align: center;
}
.progress-bar > .offCircle:before{
content: '$\A 100';
left:1.67%;
}
.progress-bar > .offCircle:after{
content: '$\A 500';
left:8.33%;
}
.progress-bar:before{
content: '$$\A 1000';
left:16.67%;
}
.progress-bar:after{
content: '$$\A 2500';
left:41.76%;
}
.progress:after{
content: '$$\A 5000';
left:83.33%;
}
<div class="row">
<div class="col-md-6">
<div class="progress">
<div class="progress-bar">
<span class="offCircle"></span>
<div class="progress-value fa fa-dollar-sign"></div>
</div>
</div>
</div>
</div>
to make it animate add css transition for the effect, you have to calculate specific value as % and pass it to a Progress-bar with javascript, you can do it in many ways.
I was finally able to complete the rest of the parts on my own.
See screenshot
In case if anyone is interested, here's the complete code:
HTML:
<div class="col-md-12">
<h3 class="heading">Money Earned to Date</h3>
<div class="row">
<div class="col-md-10">
<div class="checkout-wrap">
<ul class="checkout-bar">
<li class="visited first">
$100
</li>
<li class="previous first">$500</li>
<li class="active">
$1,000
<div class="progress-bar" style="width: 85%; background: #cc504c;"></div>
<div class="progress-value">$1,500</div>
</li>
<li class="next">$2,500</li>
<li>$5,000</li>
</ul>
<h2 class="currentMoney">$1,500.00</h2>
</div>
</div>
</div>
</div>
CSS
#-webkit-keyframes myanimation {
from {
left: 0%;
}
to {
left: 50%;
}
}
h1 {
text-align: center;
font-family: "PT Sans Caption", sans-serif;
font-weight: 400;
font-size: 30px;
padding: 20px 0;
color: #777;
}
.checkout-wrap {
color: #444;
font-family: "PT Sans Caption", sans-serif;
margin: 40px auto;
max-width: 1200px;
position: relative;
}
ul.checkout-bar {
margin: 0 20px;
}
ul.checkout-bar li {
color: #444;
display: block;
font-size: 16px;
font-weight: 600;
padding: 14px 20px 14px 80px;
position: relative;
}
ul.checkout-bar li:before {
background: #fff;
border: 2px solid #707070;
border-radius: 50%;
color: #707070;
font-size: 20px;
font-weight: 700;
left: 20px;
line-height: 37px;
height: 35px;
position: absolute;
text-align: center;
text-shadow: 1px 1px rgba(0, 0, 0, 0.2);
top: 4px;
width: 35px;
z-index: 2;
}
ul.checkout-bar li.active {
color: #444;
font-weight: bold;
padding-left: 10px;
letter-spacing: 1px;
}
ul.checkout-bar li.active:before {
background: #fff;
z-index: 3;
border-color: #707070;
color: #707070;
}
ul.checkout-bar li.visited {
background: #ECECEC;
color: #444;
z-index: 3;
padding-left: 10px;
letter-spacing: 1px;
}
ul.checkout-bar li.visited:before {
background: #fff;
z-index: 3;
border-color: #707070;
color: #707070;
}
ul.checkout-bar li:nth-child(1):before {
content: "$";
}
ul.checkout-bar li:nth-child(2):before {
content: "$";
}
ul.checkout-bar li:nth-child(3):before {
content: "$$";
}
ul.checkout-bar li:nth-child(4):before {
content: "$$";
}
ul.checkout-bar li:nth-child(5):before {
content: "$$";
}
ul.checkout-bar a {
color: #444;
font-size: 16px;
font-weight: 600;
text-decoration: none;
padding-left: 10px;
letter-spacing: 1px;
}
ul.checkout-bar li.active .progress-value{
width: 50px;
height: 25px;
font-size: 16px;
font-weight: 600;
color: #f4bc25;
line-height: 25px;
border-radius: 4px;
position: absolute;
top: -113px;
right: -23px;
letter-spacing: 1px;
}
ul.checkout-bar li.active .t_progress-bar:after{
content: "\F3C5";
font-family: "Font Awesome 5 Free";
font-weight: 900;
position: absolute;
top: -88px;
right: -10px;
font-size: 25px;
font-weight: 700;
color: #f4bc25;
}
.finances .checkout-wrap .currentMoney {
text-align: right;
padding-top: 100px;
font-size: 35px;
color: #f4bc25;
letter-spacing: 1px;
}
#media all and (min-width: 800px) {
.checkout-bar li.active:after {
-webkit-animation: myanimation 3s 0;
background-size: 35px 35px;
background-color: #f4bc25;
content: "";
height: 28px;
width: 50%;
left: 50%;
position: absolute;
top: -50px;
z-index: 0;
}
.checkout-wrap {
margin: 80px auto 0 auto
}
ul.checkout-bar {
background-size: 35px 35px;
background-color: #fff;
border-radius: 15px;
height: 30px;
margin: 0 auto;
padding: 0;
position: absolute;
width: 100%;
border: 1px solid #000;
}
ul.checkout-bar:before {
background-size: 35px 35px;
background-color: #f4bc25;
border-radius: 15px;
content: " ";
height: 28px;
left: 0;
position: absolute;
width: 10%;
}
ul.checkout-bar li {
display: inline-block;
margin: 50px 0 0;
padding: 0 0 0 20px;
text-align: center;
width: 17%;
}
ul.checkout-bar li:before {
height: 55px;
width: 55px;
left: 40%;
line-height: 55px;
position: absolute;
top: -65px;
z-index: 1;
}
ul.checkout-bar li.visited {
background: none;
}
ul.checkout-bar li.visited:after {
background-size: 35px 35px;
background-color: #f4bc25;
content: "";
height: 28px;
left: 50%;
position: absolute;
top: -50px;
width: 100%;
z-index: 1;
}
}
Ever since I added "position absoulte" to my div ".container" in my code below, my CSS animate code zooms in from the bottom then hiccups and positions itself to the center.
How can I make my animate zoom just zoom in right to the center without this hiccup where it goes down first then a second later it automatically moves to the center?
If I remove the position absolute from the .container div the animate zoom works just fine but it's not centered anymore vertically (just horizontally). The reason I used position absolute and left 0 and right 0 was to center it both ways.
Here is my code:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
top: 50%;
left: 0;
right: 0;
position: absolute;
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
background-color: white;
border: 1px solid #007580;
height: 100%;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>
You are using position:absolute and the parent element is not set with relative so the form is not relative to the scaled container which is creating this issue. You need to set position:relative to the parent container and then adjust the centering:
.box {
...
position:relative; /*Added this*/
}
.container {
...
transform:translate(0,-50%); /*Added this*/
top: 50%;
...
}
Here is the full code:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
transform:translate(0,-50%);
top: 50%;
left: 0;
right: 0;
position: absolute;
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
background-color: white;
border: 1px solid #007580;
height: 100%;
position:relative;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>
By the way it's better to consider another way than positioned element to center. You can do it with flex since you are already using it:
.box {
....
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
Then remove everything related to positionning from .container.
Here is the full code:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
background-color: white;
border: 1px solid #007580;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>
There's a few issues. In your .box styling you should add position: relative; this will force .container's absolute positioning to respect its parent, in this case .box's positioning and size. The second is the top: 50%; on .container. In certain scenarios that can seem to center the item but in others it does not. What you can do to center .container within .box is add transform: translate(0, -50%); which offsets top: 50% and centers the element. Same can be done horizontally with left: 50% and transform: translate(-50%, -50%);.
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0 auto;
color: white;
text-align: center;
font-family: 'Lato', serif;
background: linear-gradient(white 70px, #007580 70px);
-webkit-text-size-adjust: none;
}
header,
footer {
background: #007580
}
body,
main {
display: flex;
flex: 1;
}
body {
flex-flow: column;
}
header {
min-height: 35px;
}
footer {
min-height: 35px;
}
section {
margin: auto;
width: 95%;
height: 100%;
color: black;
background-color: white;
}
.categories {
position: relative;
top: 3px;
color: white;
font-size: 16px;
font-weight: 300;
word-spacing: 26px;
padding-bottom: 2px;
}
.categories a {
text-decoration: none;
color: inherit;
}
.legal {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
font-weight: 300;
word-spacing: 15px;
}
.legal a {
text-decoration: none;
font-size: 14px;
color: white;
}
.quote {
position: relative;
margin: auto;
font-size: 20px;
font-weight: 300;
bottom: 80px;
height: 0;
}
.searchcontainer {
position: relative;
height: 0;
bottom: 43px;
margin: auto;
width: 380px;
;
}
input[type=text] {
width: 100%;
display: inline-block;
border: 2px solid #ddd;
border-radius: 4px;
padding: 6px 0 7px 40px;
background-image: url('https://image.ibb.co/j9esac/searchicon.png');
background-position: 10px 6px;
background-repeat: no-repeat;
font-size: 16px;
background-color: white;
}
.innercircle {
height: 89px;
width: 89px;
border-radius: 50%;
background-color: white;
margin: auto;
position: relative;
bottom: 93px;
}
.outercircle {
height: 120px;
width: 120px;
border-radius: 50%;
background-color: #007580;
margin: auto;
position: relative;
top: 11px;
}
.D {
font-size: 100px;
font-weight: 100;
position: relative;
bottom: 196px;
right: 3px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.D a {
text-decoration: none;
color: inherit;
}
.R {
font-size: 55px;
font-weight: 100;
position: relative;
bottom: 173px;
right: 2px;
margin: auto;
color: #007580;
height: 0;
font-family: 'Amiri', serif;
letter-spacing: -10px;
}
.R a {
text-decoration: none;
color: inherit;
}
.ICONwhatsnew {
position: relative;
margin: auto;
bottom: 194px;
right: 191px;
width: 0;
display: block;
height: 0;
}
.ICONwhatsnew a {
text-decoration: none;
color: inherit;
}
.ICONworldlanguages {
position: relative;
margin: auto;
bottom: 190px;
right: 116px;
width: 0;
display: block;
height: 0;
}
.ICONworldlanguages a {
text-decoration: none;
color: inherit;
}
.ICONsignin {
position: relative;
margin: auto;
bottom: 192px;
left: 83px;
width: 0;
display: block;
height: 0;
}
.ICONsignin a {
text-decoration: none;
color: inherit;
}
.ICONcart {
position: relative;
margin: auto;
bottom: 192px;
left: 149px;
width: 0;
display: block;
height: 0;
}
.ICONcart a {
text-decoration: none;
color: inherit;
}
.container {
font-size: 17px;
font-weight: 400;
color: #007580;
top: 50%;
left: 0;
right: 0;
position: absolute;
transform: translate(0, -50%);
}
input[type=unams] {
width: 80%;
padding: 12px 45px;
margin: 22px 0 0 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/fZHHnc/signin.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
input[type=password] {
width: 80%;
padding: 12px 45px;
/* first is how big you want the input box 2nd is positioning of word password */
margin: 22px 0 15px 0;
border: 1px solid #007580;
box-sizing: border-box;
border-radius: 0px;
-webkit-appearance: none;
font-size: 17px;
background-image: url('https://image.ibb.co/jC7gfx/lock.png');
background-position: 10px 8px;
background-repeat: no-repeat;
background-size: 25px;
}
.buttonlg {
background-color: #007580;
border: none;
color: white;
width: 25%;
font-size: 17px;
height: 38px;
margin: auto;
text-align: center;
}
.outerform {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.innerform {
width: 90%;
height: 90%;
}
.box {
position: relative;
background-color: white;
border: 1px solid #007580;
height: 100%;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {
-webkit-transform: scale(0)
}
to {
-webkit-transform: scale(1)
}
}
::-webkit-input-placeholder {
/* WebKit browsers */
color: lightgrey;
opacity: 1 !important;
}
.circlelogo1 {
background: #007580;
border-radius: 50%;
height: 30px;
width: 30px;
position: relative;
margin: auto;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
.circlelogo2 {
position: absolute;
background: white;
border-radius: 50%;
height: 18px;
width: 18px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -9px 0px 0px -9px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div class="outercircle"></div>
<div class="innercircle"></div>
<div class="D">
D
</div>
<div class="R">
R
</div>
<div class="quote">
You will always be your greatest investment.
</div>
<div class="searchcontainer">
<form>
<input name="search" placeholder="Search all resources..." type="text">
</form>
</div>
<div class="ICONsignin">
<img height="37px" src="https://svgshare.com/i/5SR.svg">
</div>
<div class="ICONcart">
<img height="39px" src="https://svgshare.com/i/5SE.svg">
</div>
<div class="ICONworldlanguages">
<img height="34px" src="https://svgshare.com/i/5XW.svg">
</div>
<div class="ICONwhatsnew">
<img height="43px" src="https://svgshare.com/i/5aX.svg">
</div>
<header>
<div class="categories">
<b>Categories</b> Newest Popular Music Youth
</div>
</header>
<main>
<section>
<div class="outerform">
<div class="innerform">
<form class="animate box">
<div class="container">
<div class="circlelogo1">
<div class="circlelogo2">
</div>
</div>
<input type="unams" placeholder="Username" name="uname" required>
<input type="password" placeholder="Password" name="psw" required><br>
<button class="buttonlg" type="submit">Log In</button>
</div>
</form>
</div>
</div>
</section>
</main>
<footer>
<div class="legal">
Contact Privacy Terms Copyright About
</div>
</footer>
I am trying to emulate this nutrition label format in CSS, but I can't get the shapes right at all. The best I can come up with is fiddling with border-radius, but that gives me more of a pill shape, and still not way to get the black cut-out shape at the bottom. Has anyone replicated such a nutrition label in CSS? Would anyone be willing to try? Any help would be greatly appreciated.
Here is a link to what I have so far: jsfiddle.net/f5jczunf/
#block {
border-radius:50%/10px;
background: #ccc;
padding: 20px;
width: 50px;
height: 100px;
border: 1px solid #000;
background-color:#FFF;
text-align:center;
}
.number {
font-weight:bold;
font-size:18pt;
text-align:center;
}
<div id="block">
<span class="number">150</span>
<br/>Calories
</div>
Maybe this small example can help.
.label {
position: relative;
width: 100px;
height: 140px;
text-align: center;
border: 1px solid #000;
border-radius: 100px/50px;
overflow: hidden;
}
.title {
display: inline-block;
margin-top: 30px;
}
.bottom {
position: absolute;
bottom: -10px;
left: 0;
right: 0;
height: 50px;
color: #fff;
line-height: 40px;
border-top: 1px solid #000;
border-radius: 100px/50px;
background-color: #000;
}
<div class="label">
<span class="title">Title</span>
<span class="bottom">Bottom</span>
</div>
https://jsfiddle.net/9xs2wcbL/1/
Here's my take on it. It does require some advanced, bleeding edge CSS, however.
#import url('https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300');
body {
padding: 3em;
font-size: 16px;
font-family: 'Open Sans Condensed', sans-serif;
}
.label-list {
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
}
.label-list .label-item {
text-align: center;
border: 1px solid;
position: relative;
border-radius: 2em / 0.65em;
padding: 0.2em 0.25em 1.5em;
min-width: 3.5em;
overflow: hidden;
margin: 0.1em;
z-index: 1;
background: white;
color: black;
}
.label-list .label-item h1 {
font-size: 3em;
line-height: 1em;
font-weight: 900;
margin: 0;
}
.label-list .label-item h1.smaller {
font-size: 1.75em;
margin-top: 0.5em;
}
.label-list .label-item h1 small {
font-size: 0.4em;
text-transform: none;
}
.label-list .label-item small {
font-size: 1em;
line-height: 1em;
font-weight: 900;
text-transform: uppercase;
}
.label-list .label-item span {
position: absolute;
bottom: 0.5em;
left: 0;
right: 0;
color: white;
font-size: 0.8em;
line-height: 1em;
}
.label-list .label-item span:before {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
background: black;
z-index: -1;
border-radius: 40%;
transform-origin: center;
width: 100%;
height: 0;
padding-top: 100%;
margin: auto;
transform: rotate(45deg) translate(20%, 20%);
}
<div class="label-list">
<div class="label-item">
<h1>140</h1>
<small>Calories</small>
</div>
<div class="label-item">
<h1 class="smaller">1<small>g</small></h1>
<small>Sat Fat</small>
<span>5% DV</span>
</div>
</div>
I believe the only way to have this sort of shape in pure CSS is with a few overlapping shapes, something similar to the code below:
.wrapper {
position: relative;
height: 112px;
width: 80px;
overflow: hidden;
}
.rectangle,
.circle {
position: absolute;
box-sizing: border-box;
}
.rectangle {
height: 96px;
width: 80px;
top: 8px;
border-left: 1px solid black;
border-right: 1px solid black;
}
.circle {
width: 200px;
height: 200px;
left: -60px;
border-radius: 200px;
border: 1px solid black;
}
.top {
top: 0;
}
.bottom {
bottom: 0;
}
<div class="wrapper">
<div class="circle top"></div>
<div class="rectangle"></div>
<div class="circle bottom"></div>
</div>
https://jsfiddle.net/dylanstark/01hck5dv/
here my approach for that. I'm using before and after pseudo-elements.
before contains black bg with border-radius and it is overflowing the main #block which has overflow: hidden;.
aftercontains text that is coming from data-text attribute of #block
#block {
border-radius: 50%/10px;
background: #ccc;
padding: 20px;
width: 50px;
height: 100px;
border: 1px solid #000;
background-color: #FFF;
text-align: center;
position: relative;
overflow: hidden;
}
#block:before {
display: block;
content: " ";
position: absolute;
bottom: -15px;
left: 0;
width: 100%;
height: 50px;
border-radius: 50%;
background: black;
z-index: 0;
}
#block:after {
display: block;
content: attr(data-label);
position: absolute;
bottom: 5px;
color: white;
text-align: center;
z-index: 1;
}
.number {
font-weight: bold;
font-size: 18pt;
text-align: center;
}
<div id="block" data-label="5% DY">
<span class="number">150</span>
<br/>Calories
</div>
My image is inside a well which has fixed width fixed.
(1) How to get my image always horizontally centered (I tried using
margin:0 auto but it didnt work).
(2) Also I have an .overlay
and it works for all my other images (which have the
max-width:300px, but for images as in example with smaller width,
I need the overlay to also cover a full max-width of the well (now as in this example, the overlay is limited to the width of these smaller-width images). How to make
these 2 things possible?
.image-video-linkcar {
position: relative;
display: inline-block;
}
.image-video-linkcar img {
max-width: auto;
max-height: 230px;
margin: 0;
padding: 0;
vertical-align: middle;
}
.categorycar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat',sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #FFF;
opacity: .9;
position: absolute;
opacity: .7;
bottom: 0;
right: 0;
min-height: 0;
}
.brandcar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat',sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #fff;
opacity: .9;
position: absolute;
opacity: .7;
top: 0;
right: 0;
min-height: 0;
}
.image-video-linkcar:hover .overlay {
opacity: 1;
}
.well.carousel {
width: 100%;
height: auto;
height: 420px;
width: 400px;
padding: 0;
margin: 0;
border: none;
background-color:red
}
.product-detailscar .overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
border-radius: 0;
background: #F7F7F7;
color: #FFF;
padding: 10px;
border-top: 1px solid #A10000;
border-bottom: 1px solid #A10000;
/*vertical-align: middle;*/
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
/*padding: 25px;
text-align: center;*/
}
<div class="well carousel">
<div class="product-detailscar">
<div class="image-video-linkcar">
<img alt="#" src=
"http://lorempixel.com/100/200">
<div class="brandcar">
BRAND
</div>
<div class="categorycar">
CATEGORY
</div>
<div class="overlay">
<div class="subcategorycar">
SUBCAT
</div>
<div class="idcar">
ID
</div>
You need to move the overlay out of the .product-detailscar div.
.well {
width: 300px;
background: orange;
position: relative;
text-align: center;
}
.image-video-linkcar {
position: relative;
display: inline-block;
}
.image-video-linkcar img {
max-width: auto;
max-height: 230px;
margin: 0;
padding: 0;
vertical-align: middle;
}
.categorycar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat', sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #FFF;
opacity: .9;
position: absolute;
opacity: .7;
bottom: 0;
right: 0;
min-height: 0;
}
.brandcar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat', sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #fff;
opacity: .9;
position: absolute;
opacity: .7;
top: 0;
right: 0;
min-height: 0;
}
.well:hover .overlay {
opacity: 1;
}
.well .overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
border-radius: 0;
background: rgba(0, 255, 0, .5);
color: #FFF;
padding: 10px;
border-top: 1px solid #A10000;
border-bottom: 1px solid #A10000;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="well carousel">
<div class="product-detailscar">
<div class="image-video-linkcar">
<img alt="#" src="http://www.fillmurray.com/100/200">
<div class="brandcar">
BRAND
</div>
<div class="categorycar">
CATEGORY
</div>
</div>
</div>
<div class="overlay">
<div class="subcategorycar">
SUBBBBBBCATEGORY
</div>
<div class="idcar">
IDDDDCAR
</div>
</div>
</div>
I am trying to place content-desc div to the bottom of content-box-inner but it's not placing there, it's going just after the image:
.content-box-inner {
position: relative;
display: inline-block;
width: 360px;
height: 460px;
background-color: #fff;
margin-right: 10px;
border: 1px solid #ddd;
overflow: hidden;
}
.content-box-inner > img {
width: 200px;
margin-top: 10px;
border: 1px solid #ddd;
padding: 8px;
}
.content-title {
position: relative;
height: 35px;
background-color: #FFB400;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.3)
}
.content-title > p {
text-align: center;
line-height: 35px;
font-family: verdana;
color: #222;
font-weight: bold;
letter-spacing: 0.02em;
text-transform: capitalize;
}
.content-desc {
position: relative;
height: 50px;
bottom: 0;
left: 0;
right: 0;
}
.content-desc > p {
font-family: verdana;
letter-spacing: 0.04em;
font-size: 15px;
padding: 8px;
}
<div class="content-box-inner">
<div class="content-title">
<p>text</p>
</div>
<img src="img.jpg">
<div class="content-desc">
<p>some text</p>
</div>
</div>
Does anyone know, what I did wrong in my CSS?
Have you tried using position: absolute;? adding position: absolute; bottom: 0; should fix your issues.
Change
.content-desc {
position: relative;
...
}
to
.content-desc {
position: absolute;
...
}
you will want your .content-desc to be set to absolute positioning:
.content-box-inner {
position: relative;
display: inline-block;
width: 360px;
height: 460px;
background-color: #fff;
margin-right: 10px;
border: 1px solid #ddd;
overflow: hidden;
}
.content-box-inner > img {
width: 200px;
margin-top: 10px;
border: 1px solid #ddd;
padding: 8px;
}
.content-title {
position: relative;
height: 35px;
background-color: #FFB400;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.3)
}
.content-title > p {
text-align: center;
line-height: 35px;
font-family: verdana;
color: #222;
font-weight: bold;
letter-spacing: 0.02em;
text-transform: capitalize;
}
.content-desc {
position: absolute;
height: 50px;
bottom: 0;
left: 0;
right: 0;
}
.content-desc > p {
font-family: verdana;
letter-spacing: 0.04em;
font-size: 15px;
padding: 8px;
}
see link to fiddle here: https://jsfiddle.net/john_h/w05hwuxp/