Delete gap between stacked upper and lower boxes - html

I created a fiddle here : http://jsfiddle.net/celiostat/zgUgn/
this is for a dynamic webpage. depending on the user, their might be 4 (as in the example) or 13 collections (on square = one collection). Height of image and collection title can vary. Consequently boxe height varies, and on the second row, I get a gap between collection above and collection below whereas I would like to keep that space between the boxes even; say 25px.
Thanks for your help !
HTML:
<div class="collection_bookmars_container">
<img class="collection_random_image" src="http://img.foodnetwork.com/FOOD/2012/05/04/FNM-060112_NTD-Hot-Dog-Sandwich_s4x3_lg.jpg">
<div class="collection_bookmark_title_container">
<span class="collection_bookmark_title">Thai favorites</span>
</div>
<div class="modify_collection_container">
<span class="number_of_articles">1</span>
<span class="article_text_only">articles</span>
<img class="icon_modify_collection" src="http://www.mricons.com/store/png/124258_43263_128_monotone_pen_write_icon.png">
</div>
</div>
<div class="collection_bookmars_container">
<img class="collection_random_image" src="http://img.foodnetwork.com/FOOD/2013/07/19/FNM_090113-Name-This-Dish-Stacked-Salad-Recipe_s4x3_lg.jpg">
<div class="collection_bookmark_title_container">
<span class="collection_bookmark_title">Best France food stuff</span>
</div>
<div class="modify_collection_container">
<span class="number_of_articles">1</span>
<span class="article_text_only">articles</span>
<img class="icon_modify_collection" src="http://www.mricons.com/store/png/124258_43263_128_monotone_pen_write_icon.png">
</div>
</div>
<div class="collection_bookmars_container">
<img class="collection_random_image" src="http://img.foodnetwork.com/FOOD/2012/05/04/FNM-060112_NTD-Hot-Dog-Sandwich_s4x3_lg.jpg">
<div class="collection_bookmark_title_container">
<span class="collection_bookmark_title">Snacks</span>
</div>
<div class="modify_collection_container">
<span class="number_of_articles">1</span>
<span class="article_text_only">articles</span>
<img class="icon_modify_collection" src="http://www.mricons.com/store/png/124258_43263_128_monotone_pen_write_icon.png">
</div>
</div>
<div class="collection_bookmars_container">
<img class="collection_random_image" src="http://www.secondhomemalaysia.co.uk/uploads/Food3.jpg">
<div class="collection_bookmark_title_container">
<span class="collection_bookmark_title">Soups and veloutes</span>
</div>
<div class="modify_collection_container">
<span class="number_of_articles">1</span>
<span class="article_text_only">articles</span>
<img class="icon_modify_collection" src="http://www.mricons.com/store/png/124258_43263_128_monotone_pen_write_icon.png">
</div>
</div>
CSS:
body
{
background-color: #ECF0F1;
}
.container
{
max-width: 550px;
width: 100%;
margin: 0px auto;
position: relative;
}
.table_presentation_two_column
{
height: auto;
display: table;
width: 100%;
margin: 0 auto;
}
.collection_bookmars_container
{
height: auto;
background-color: white;
display: inline-block;
vertical-align: top;
width: 46%;
box-sizing: border-box;
margin: 20px 2% 0% 2%;
}
.collection_random_image
{
margin-bottom: 10px;
width: 100%;
}
.collection_bookmark_title_container
{
margin: 30px 4% 0px 4%;
}
.collection_bookmark_title
{
font-family: "Roboto Slab","serif";
font-size: 30px;
}
.modify_collection_container
{
margin-top: 10px;
margin: 20px 4% 0px 4%;
padding-top: 15px;
border-top: 3px solid #EBEBEB;
width: 92%;
}
.number_of_articles
{
font-size: 16px
font-family: "Montserrat";
padding-bottom: 4px;
color: #AFAFAF;
font-weight: bold;
}
.article_text_only
{
font-size: 16px;
font-family: "Montserrat";
padding-bottom: 4px;
color: #AFAFAF;
font-weight: bold;
}
.icon_modify_collection
{
float: right;
position: relative;
overflow: hidden;
width: 12%;
max-width: 250px;
padding-bottom: 10px;
margin-top: -5;
}

You will need something like Masonry (http://masonry.desandro.com/) to do what you want, there is no other way doing it nicely because of the height difference. The wrapper is what is wrecking it for you.
Perhaps another idea is to create the wrappers for each column instead of each row.

Related

Div inside a div has a top margin which I cannot figure out how to remove

I'm new to HTML and CSS and have been following a course on them. One of the objectives was to try to make a rough basic copy of the visuals of any website we'd like in order to practice what we learned - so I picked the Gitlab front page.
Was progressing fine until I reached this 'Get Free Trial' div. My idea was to set the Get Free Trial div inside the outer div and center it. No matter what I do, however, there is always this margin/padding from the top that I can't get rid of and I have no idea why it is there.
#topbar {
height: 68px;
}
#adbar {
background-color: #9B51E0;
height: 60px;
}
#main {
background-color: white;
}
body {
margin: 0;
padding: 0;
}
#logo-div {
height: 68px;
width: 155px;
float: left;
}
#logo {
margin: 10px 20px 10px 20px;
width: 108px;
}
.menu-div {
width: 100px;
height: 68px;
float: left;
}
.menu-text {
text-align: center;
font-size: 90%;
font-weight: bold;
font-family: Arial;
color: #929292;
margin-top: 27px;
}
.menu-text:hover {
color: #9B51E0;
}
#search-div {
width: 530px;
float: left;
height: 68px;
}
#search {
float: right;
width: 13px;
margin-right: 25px;
margin-top: 25px;
}
#trial-div {
width: 140px;
background-color: burlywood;
float: left;
height: 68px;
}
#trial-button {
height: 70%;
width: 90%;
background-color: #FA7035;
color: white;
border-radius: 10%;
}
#trial-text {
text-align: center;
font-weight: bold;
font-size: 90%;
font-family: Arial;
margin-top: 10px;
margin-bottom: 25px;
}
<div id="topbar">
<div id="logo-div">
<img src="logo2.PNG" id="logo">
</div>
<div class="menu-div">
<p class="menu-text">Product</p>
</div>
<div class="menu-div">
<p class="menu-text">Solutions</p>
</div>
<div class="menu-div">
<p class="menu-text">Resources</p>
</div>
<div class="menu-div">
<p class="menu-text">Partners</p>
</div>
<div class="menu-div">
<p class="menu-text">Pricing</p>
</div>
<div class="menu-div">
<p class="menu-text">Support</p>
</div>
<div id="search-div">
<img src="search.png" id="search">
</div>
<div id="trial-div">
<div id="trial-button">
<p id="trial-text">Get free trial</p>
</div>
</div>
</div>
<div id="adbar">
</div>
<div id="main">
</div>
Any ideas and could I ask for an explanation of why this happens? Thank you!
If your final goal is to center the inner div (get free trial) inside outer div:
<div id="trial-div" style="display:flex;justify-content:center;align-items:center;">
#topbar {
height: 68px;
}
#adbar {
background-color: #9B51E0;
height: 60px;
}
#main {
background-color: white;
}
body {
margin: 0;
padding: 0;
}
#logo-div {
height: 68px;
width: 155px;
float: left;
}
#logo {
margin: 10px 20px 10px 20px;
width: 108px;
}
.menu-div {
width: 100px;
height: 68px;
float: left;
}
.menu-text {
text-align: center;
font-size: 90%;
font-weight: bold;
font-family: Arial;
color: #929292;
margin-top: 27px;
}
.menu-text:hover {
color: #9B51E0;
}
#search-div {
width: 530px;
float: left;
height: 68px;
}
#search {
float: right;
width: 13px;
margin-right: 25px;
margin-top: 25px;
}
#trial-div {
width: 140px;
background-color: burlywood;
float: left;
height: 68px;
}
#trial-button {
height: 70%;
width: 90%;
background-color: #FA7035;
color: white;
border-radius: 10%;
}
#trial-text {
text-align: center;
font-weight: bold;
font-size: 90%;
font-family: Arial;
margin-top: 10px;
margin-bottom: 25px;
}
<div id="topbar">
<div id="logo-div">
<img src="logo2.PNG" id="logo">
</div>
<div class="menu-div">
<p class="menu-text">Product</p>
</div>
<div class="menu-div">
<p class="menu-text">Solutions</p>
</div>
<div class="menu-div">
<p class="menu-text">Resources</p>
</div>
<div class="menu-div">
<p class="menu-text">Partners</p>
</div>
<div class="menu-div">
<p class="menu-text">Pricing</p>
</div>
<div class="menu-div">
<p class="menu-text">Support</p>
</div>
<div id="search-div">
<img src="search.png" id="search">
</div>
<div id="trial-div" style="display:flex;justify-content:center;align-items:center;">
<div id="trial-button">
<p id="trial-text">Get free trial</p>
</div>
</div>
</div>
<div id="adbar">
</div>
<div id="main">
</div>
Without being able to see everything, did you reset the styles from the browser? Each browser comes with a built in style sheet that has padding and margins. I recommend loading a reset.css stylesheet BEFORE your actual stylesheet. This will clear all browser styles. Make sure yours is second otherwise the reset will override yours.
Here is the reset styles I use:
https://meyerweb.com/eric/tools/css/reset/
I figured it out, it was the CSS code in my trial-text id. Putting margins there sets a margin in relation to the trial-div div and not the trial-button div. This forces the trial-button div to also apply a margin.
Not sure why exactly this happens and it doesnt apply a margin to the trial-button div though

Can you find the error in this html/css code?

The result should be looking like this, as it appears in Edge:
This is how it looks when rendered in Chrome; as you may notice the search box is misplaced, on the line below the category bar:
The raw code:
Please help me to find the error that makes the search box appear on the lower line. I have been through this from start to finish for hours, and can't figure out why the same code looks fine in Edge, but not in Chrome.
I won't switch browsers, I need a solution for this to keep operating with
Chrome.
#topbar {
width: 1000px;
margin: 0 auto;
height: 40px;
}
body {
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
}
#logo {
margin-top: 8px;
width: 100px;
float: left;
margin-right: 8px;
}
.topbar-section {
float: left;
border-left: 1px #CCCCCC solid;
height: 100%;
}
#signin-image {
width: 25px;
margin: 11px 15px;
float: left;
}
#signin-text {
font-weight: bold;
font-size: 90%;
position: relative;
top: 14px;
padding-right: 50px;
}
#wigglyline {
float: left;
height: 40px;
}
#bell {
height: 25px;
margin: 9px 8px;
}
#bell-div {
float: left;
}
.topbar-menu {
font-weight: bold;
font-size: 90%;
padding: 13px 15px 0 15px;
height: 27px;
}
#more-arrow {
width: 16px;
margin-left: 20px;
}
#search-box {
background-color: #E4E4E4;
border: none;
font-weight: bold;
font-size: 14px;
padding: 5px;
margin: 5px 0 5px 5px;
float: left;
}
#magnifying-glass {
height: 26px;
margin-top: 5px;
}
.clear {
clear: both;
}
#menu-bar-container {
background-color: #BB1919;
width: 100%;
height: 100px;
}
#menu-bar {
width: 1000px;
margin: 0 auto;
}
h1 {
padding: 0;
margin: 0;
color: white;
font-size: 40px;
font-weight: normal;
padding-top: 10px;
}
<div id="topbar">
<img id="logo" src="images/bbc-blocks-dark.png">
<div id="signin-div" class="topbar-section">
<img id="signin-image" src="images/signinimage.png">
<span id="signin-text">Sign in</span>
</div>
<div id="bell-div">
<img id="wigglyline" src="images/wigglyline.png">
<img id="bell" src="images/bell.png">
</div>
<div class="topbar-section topbar-menu">
News
</div>
<div class="topbar-section topbar-menu">
Sport
</div>
<div class="topbar-section topbar-menu">
Weather
</div>
<div class="topbar-section topbar-menu">
iPlayer
</div>
<div class="topbar-section topbar-menu">
TV
</div>
<div class="topbar-section topbar-menu">
More
<img id="more-arrow" src="images/more-arrow.png">
</div>
<div class="topbar-section">
<input id="search-box" type="text" value="Search">
<input type="image" id="magnifying-glass" src="images/magnifying-glass.png">
</div>
</div>
<div class="clear"></div>
<div id="menu-bar-container">
<div id="menu-bar">
<h1>NEWS</h1>
</div>
</div>
It's because the width of your container isn't big enough. If you make the width of #topbar 1100px then it won't wrap.
#topbar {
width: 1100px;
margin: 0 auto;
height: 40px;
}
body {
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
}
#logo {
margin-top: 8px;
width: 100px;
float: left;
margin-right: 8px;
}
.topbar-section {
float: left;
border-left: 1px #CCCCCC solid;
height: 100%;
}
#signin-image {
width: 25px;
margin: 11px 15px;
float: left;
}
#signin-text {
font-weight: bold;
font-size: 90%;
position: relative;
top: 14px;
padding-right: 50px;
}
#wigglyline {
float: left;
height: 40px;
}
#bell {
height: 25px;
margin: 9px 8px;
}
#bell-div {
float: left;
}
.topbar-menu {
font-weight: bold;
font-size: 90%;
padding: 13px 15px 0 15px;
height: 27px;
}
#more-arrow {
width: 16px;
margin-left: 20px;
}
#search-box {
background-color: #E4E4E4;
border: none;
font-weight: bold;
font-size: 14px;
padding: 5px;
margin: 5px 0 5px 5px;
float: left;
}
#magnifying-glass {
height: 26px;
margin-top: 5px;
}
.clear {
clear: both;
}
#menu-bar-container {
background-color: #BB1919;
width: 100%;
height: 100px;
}
#menu-bar {
width: 1000px;
margin: 0 auto;
}
h1 {
padding: 0;
margin: 0;
color: white;
font-size: 40px;
font-weight: normal;
padding-top: 10px;
}
<div id="topbar">
<img id="logo" src="images/bbc-blocks-dark.png">
<div id="signin-div" class="topbar-section">
<img id="signin-image" src="images/signinimage.png">
<span id="signin-text">Sign in</span>
</div>
<div id="bell-div">
<img id="wigglyline" src="images/wigglyline.png">
<img id="bell" src="images/bell.png">
</div>
<div class="topbar-section topbar-menu">
News
</div>
<div class="topbar-section topbar-menu">
Sport
</div>
<div class="topbar-section topbar-menu">
Weather
</div>
<div class="topbar-section topbar-menu">
iPlayer
</div>
<div class="topbar-section topbar-menu">
TV
</div>
<div class="topbar-section topbar-menu">
More
<img id="more-arrow" src="images/more-arrow.png">
</div>
<div class="topbar-section">
<input id="search-box" type="text" value="Search">
<input type="image" id="magnifying-glass" src="images/magnifying-glass.png">
</div>
</div>
<div class="clear"></div>
<div id="menu-bar-container">
<div id="menu-bar">
<h1>NEWS</h1>
</div>
</div>
It's because you've set the width property of the ID top-bar to 1000. Search bar cannot fit in (At least in chrome, maybe because of default browser margins)
Make the width property to something like 1050px to solve it.
#topbar {
width: 1050px;
margin: 0 auto;
height: 40px;
}
It works!

Inexplicable gap in between my divs

I am trying to replicate the BBC News site and I have this weird styling problem.
Here is the image.
I always get this gap in between two of my divs.
Here is the code I used. Not sure how I am supposed to go about getting rid of that space. tried setting margin and padding to 0 but that didn't work.
Here is the code:
body{
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
}
#topbar{
height: 40px;
width: 1000px;
margin: 0 auto;
background-color: #FFFFFF;
}
#logo{
float: left;
margin-top: 8px;
margin-right: 8px;
}
.topbarsections{
float:left;
border-left: 1px #CCCCCC solid;
height: 100%;
}
#signin-image{
float: left;
width: 30px;
margin-top: 7px;
margin-left: 8px;
}
#signin-text{
float: left;
font-weight: bold;
font-size: 90%;
color: #333333;
position: relative;
top: 13px;
padding-right: 80px;
}
.topbar-menu{
float: left;
font-weight: bold;
color: #333333;
font-size: 90%;
padding: 13px 15px 0 15px;
height: 27px;
}
#more-arrow{
height: 13px;
margin-left: 15px;
}
#search-box{
background-color: #E4E4E4;
margin: 8px 0 0 10px;
border: none;
font-weight: bold;
font-size: 14px;
padding: 5px;
width: 140px;
float: left
}
#magnifying-glass{
margin-top: 8px;
height: 26px;
}
.clear{
margin: 0;
padding: 0;
}
#news-bar{
background-color: #BB1919;
width: 100%;
height: 70px;
}
#inner-news-bar{
background-color: #BB1919;
margin: 0 auto;
width: 1200px;
height: 70px;
}
#news-bar h1{
color: white;
margin: 0;
padding: 10px;
font-weight: normal;
font-size: 45px;
}
#menu-bar{
background-color: #A91717;
width: 100%;
height: 35px;
}
#inner-menu-bar{
background-color: #A91717;
width: 1200px;
height: 35px;
margin: 0 auto;
}
.menu-bar-sections{
float: left;
border-right: 1px solid #BB4545;
padding-left: 10px;
padding-right:8px;
position: relative;
top: -5px;
}
.menu-bar-sections a{
float:left;
color: white;
text-decoration: none;
}
.menu-bar-sections a:hover{
text-decoration: underline;
}
#menu-bar-more-section{
border-right: none !important;
}
#down-arrow{
float: left;
height: 13px;
position: relative;
top: 2px;
margin-left: 2px;
}
#page-container{
width: 1200px;
margin: 0 auto;
}
h2{
}
<body>
<div id="topbar">
<img id="logo" src="images/bbclogo.png">
<div id="signin-div" class="topbarsections">
<img src="images/singin.PNG" id="signin-image">
<span id="signin-text">Sign in</span>
</div>
<div class="topbarsections topbar-menu">
News
</div>
<div class="topbarsections topbar-menu">
Sports
</div>
<div class="topbarsections topbar-menu">
Weather
</div>
<div class="topbarsections topbar-menu">
Shop
</div>
<div class="topbarsections topbar-menu">
Earth
</div>
<div class="topbarsections topbar-menu">
Travel
</div>
<div class="topbarsections topbar-menu">
More
<img id="more-arrow"src="images/more-arrow.PNG">
</div>
<div class="topbarsections">
<input id="search-box" type="text" placeholder="Search">
<input type="image" id="magnifying-glass" src="images/glass.PNG">
</div>
</div>
<div class="clear"></div>
<div id="news-bar">
<div id="inner-news-bar">
<h1>NEWS</h1>
</div>
</div>
<div class="clear"></div>
<div id="menu-bar">
<div id="inner-menu-bar">
<p class="menu-bar-sections">Home</p>
<p class="menu-bar-sections">Video</p>
<p class="menu-bar-sections">World</p>
<p class="menu-bar-sections">US & Canada</p>
<p class="menu-bar-sections">UK</p>
<p class="menu-bar-sections">Business</p>
<p class="menu-bar-sections">Tech</p>
<p class="menu-bar-sections">Science</p>
<p class="menu-bar-sections">Stories</p>
<p class="menu-bar-sections">Entertainment & Arts</p>
<p class="menu-bar-sections">Health</p>
<p class="menu-bar-sections" id="menu-bar-more-section">More<img src="images/down-arrow.PNG" id="down-arrow"></p>
</div>
</div>
<div class="clear"></div>
<div id="page-container">
<div id="main-article">
<h2>Technology</h2>
</div>
</div>
</body>
If by "gap" you mean the space above the heading "Technology", #Olivier Krull is right: that's the default margin of the h2 header.
You can simply add this CSS rule to set it to zero:
#main-article > h2:first-child {
margin-top: 0;
}

External CSS files causing problems to images

This is NetBeans. I have tried to include an external CSS file but when used externally the images all get really enlarged. Whereas my I use the same styling within the html file using internal styling the images are of correct ratio.
body {
width: 100%;
height: 100%;
margin: 0;
}
.header {
background-color: #000;
color: #fff;
border-color: #080808;
min-height: 50px;
border: 1px solid transparent;
}
.inner header {
width: 80%;
margin: auto;
}
.logo {
float: left;
height: 50px;
padding: 15px;
font-size: 20px;
font-weight: bold;
padding-left: 90px;
}
a {
text-decoration: none;
background-color: transparent;
color: #ededed;
}
.header link {
float: right;
font-size: 14px;
height: 50px;
padding: 15px 15px;
font-size: 16px;
font-weight: bold;
}
#su {
float: right;
height: 50px;
padding: 15px 90px;
}
#l {
float: right;
height: 50px;
padding: 15px 0px;
}
.content {
min-height: 600px;
}
.banner-image {
padding-bottom: 50px;
margin-bottom: 20px;
text-align: center;
color: #f8f8f8;
background: url(image/intro-bg_1.jpg) no-repeat center;
background-size: cover;
}
.inner-banner-image {
padding-top: 12%;
width: 80%;
margin: auto;
}
.banner-content {
position: relative;
padding-top: 6%;
padding-bottom: 6%;
overflow: hidden;
margin-bottom: 12%;
background-color: rgba(0, 0, 0, 0.7);
max-width: 660px;
margin-left: 200px;
}
.button {
color: #fff;
background-color: #c9302c;
border-color: #ac2925;
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
padding: 10px 16px;
font-size: 18px;
border-radius: 6px;
}
.container {
width: 90%;
margin: auto;
overflow: hidden;
}
.items {
width: 30%;
display: block;
padding: 4px;
margin-bottom: 20px;
line-height: 1.42857143;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
float: left;
margin-left: 1%;
}
.thumbnail {
display: block;
max-width: 100%;
height: auto;
}
.caption {
color: #000;
padding: 0px 10px 10px;
font-weight: bold;
text-align: center;
}
footer {
background-color: #000;
color: #fff;
font-size: 14px;
text-align: center;
}
<html>
<head>
<title>Lifestyle Store</title>
</head>
<body>
<div class="header">
<div class="inner header">
<div class="logo">
Lifestyle Store
</div>
<div class="header link">
<div id="su">
Sign Up
</div>
<div id="l">
Login
</div>
</div>
</div>
</div>
<div class="content">
<div class="banner-image">
<div class="inner-banner-image ">
<div class="banner-content">
<h1>We sell lifestyle</h1>
<p>Flat 40% OFF on premium brands</p>
<form>
Shop Now
</form>
</div>
</div>
</div>
</div>
<div class="container">
<div class="items">
<a href="#">
<img src="image/camera.jpg" class="thumbnail">
<div class="caption">
<h2>Cameras</h2>
<p>Choose among the best from the world</p>
</div>
</a>
</div>
<div class="items">
<a href="#">
<img src="image/watch.jpg" class="thumbnail">
<div class="caption">
<h2>Watches</h2>
<p>Original watches from the best brands</p>
</div>
</a>
</div>
<div class="items">
<a href="#">
<img src="image/shirt.jpg" class="thumbnail">
<div class="caption">
<h2>Shirts</h2>
<p>Our exquisite collection of shirts</p>
</div>
</a>
</div>
</div>
<footer>
<div class="container">
<p>Copyright © Lifestyle Store. All Rights Reserved | Contact Us: +91 90000 00000</p>
</div>
</footer>
</body>
</html>
Have you linked the CSS file correctly in this line? Try dragging and dropping the file directly into the HTML to ensure the location and name is correct.
href="assignment1/public_html/style.css"
Edit:
The current link you have is saying that you have the index.html file outside of the 'assignment1' folder. If you have your HTML file inside 'public_html' then the stylesheet link should be the following.
href="style.css"

How to force DIV to take up the height of the parent

<div class="dispLoginSearch"> <!-- LOGIN AND SEARCH -->
<div class="loginBox">
<div class="loginTopHolder hidOverflow">
<div class="floatLeft setCenter hidOverflow" style="width: 45%;">
<span class="myText">My</span>
<br /><br />
<span class="wmText">Login</span>
</div>
<div class="floatRight hidOverflow" style="height: 100%; background: #FF0000;">
<div class="hidOverflow brClear" style="height: 50%; background: #0000FF;">
<input type="submit" name="ctl00$SubmitLoginNM" value="Login" id="ctl00_SubmitLoginNM" class="styledBtn logBtn floatLeft lightLinks" />
</div>
<div class="hidOverflow brClear" style="height: 50%; font-size: small; display: table-cell; vertical-align: bottom;">
Register a New Account
<br />
Forgot Username/Password
</div>
</div>
</div>
</div>
</div> <!-- LOGIN AND SEARCH -->
CSS:
CSS:
.dispLoginSearch {
width: 40%;
height: 100%;
vertical-align: middle;
float: right;
padding-right: 2%;
background: #FFFFFF;
overflow: hidden;
text-align: center;
margin: 0 auto;
}
.loginBox {
margin-top: 3%;
border: 1px solid #d4d4d4;
display: block;
width: 95%;
font: 16px sans-serif;
padding: 0 0 0 15px;
border-radius: 5px;
-webkit-font-smoothing: antialiased;
text-align: left;
overflow: auto;
}
.loginTopHolder {
width: 95%;
margin: 5px 5px 5px 5px;
height: 85px;
}
.hidOverflow {
overflow: hidden;
}
.setCenter {
text-align: center;
}
.brClear {
clear: both;
}
.floatLeft {
float: left;
}
.floatRight {
float: right;
}
Output:
I want the green DIV to get the 50% of the height and align the text bottom, but can't seem to get it done.
Please help me resolve it.
The parent element should be defines as position: absolute; so the child elements width and height depends on that