Creating padding in grids and still equal heights - html

I've created a grid banner where I'm trying to implement a padding between the columns.
However, when I do this it seem to mess up the heights. How can I do this without messing up heights?
As you can see if you add following code in a html doc, the item normal-size will be bigger than the double-size column. I've applied padding on column-small-1, column-small-2, normal-size and double-size, but as you can see it does not seem to align properly?
.wrapper {
width: 100%;
height: auto;
}
.item {
float: left;
}
.double-size {
box-sizing: border-box;
width: 66.6666%;
height: auto;
padding-right: 8px;
}
.normal-size {
box-sizing: border-box;
width: 33.3333%;
height: auto;
padding-left: 8px;
}
.double-size .column-big {
box-sizing: border-box;
width: 100%;
height: auto;
}
.normal-size .column-small-1 {
box-sizing: border-box;
width: 100%;
height: auto;
padding: 0px 0px 8px 0px;
}
.normal-size .column-small-2 {
box-sizing: border-box;
width: 100%;
height: auto;
padding: 8px 0px 0px 0px;
}
.column-content {
position: relative;
overflow: hidden;
}
.column-content .meta-info-doub {
box-sizing: border-box;
position: absolute;
height: auto;
width: 100%;
bottom: 0;
right: 0;
padding: 40px;
}
.column-content .meta-info-norm {
box-sizing: border-box;
position: absolute;
height: auto;
width: 100%;
bottom: 0;
right: 0;
padding: 20px;
}
.title-double {
font-family: 'Open Sans', sans-serif;
font-size: 20px;
line-height: 1.65;
background: #161616;
background: rgba(22, 22, 22, 0.5);
color: #fff;
display: inline;
padding: 4px 0;
margin: 0;
-webkit-box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
text-transform: uppercase;
}
.title-normal {
font-family: 'Open Sans', sans-serif;
font-size: 17px;
line-height: 1.65;
background: #161616;
background: rgba(22, 22, 22, 0.5);
color: #fff;
display: inline;
padding: 4px 0;
margin: 0;
-webkit-box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
text-transform: uppercase;
}
.date-double {
font-family: 'Open Sans', sans-serif;
display: inline;
color: #fff;
font-size: 11px;
text-shadow: 0 1px 0 #222;
text-transform: uppercase;
margin-bottom: 11px;
display: block;
}
.date-normal {
font-family: 'Open Sans', sans-serif;
display: inline;
color: #fff;
font-size: 11px;
text-shadow: 0 1px 0 #222;
text-transform: uppercase;
margin-bottom: 11px;
display: block;
}
.column-content .content-image {
height: auto;
width: 100%;
background-size: 100%;
display: block;
-moz-transition: all .5s;
-webkit-transition: all .5s;
transition: all .5s;
}
.column-content .content-image:hover {
-moz-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
<div class="wrapper">
<div class="item double-size">
<div class="column-big">
<div class="column-content">
<img src="http://blognewswp.gotheme.net/wp-content/uploads/2014/08/shutterstock_190029455_supersize-640x400.jpg" href="#" id="img-zoom" class="content-image">
<div class="meta-info-doub">
<h3 class="date-double">23. Oktober 2015</h3>
<h3 class="title-double">Post2</h3>
</div>
</div>
</div>
</div>
<div class="item normal-size">
<div class="column-small-1">
<div class="column-content">
<img src="http://blognewswp.gotheme.net/wp-content/uploads/2014/08/shutterstock_190029455_supersize-640x400.jpg" href="#" id="img-zoom" class="content-image">
<div class="meta-info-norm">
<h3 class="date-double">23. Oktober 2015</h3>
<div class="info-title">
<h3 class="title-normal">Post 3</h3>
</div>
</div>
</div>
</div>
<div class="column-small-2">
<div class="column-content">
<img src="http://blognewswp.gotheme.net/wp-content/uploads/2014/08/shutterstock_190029455_supersize-640x400.jpg" href="#" id="img-zoom" class="content-image">
<div class="meta-info-norm">
<h3 class="date-double">23. Oktober 2015</h3>
<div class="info-title">
<h3 class="title-normal">Post1</h3>
</div>
</div>
</div>
</div>
</div>
</div>

Can you fix the height of the row? If not, the best I can think of is having your two .item vertically align correctly. Which I would do by adding:
.item {
display:inline-block;
vertical-align:middle;
}
And removing the float:left that was previously on .item. This will also require you remove the whitespace between the closing and opening tags of two .items or apply one of the other techniques for inline-block gaps mentioned "How to remove the space between inline-block elements?".
Edit: There is probably a flexbox based solution if you can restrict your support to quite modern browsers.
Edit: http://jsfiddle.net/a2q3rr30/ is the flexbox solution linked below. It uses a combination of flex, a position absolute trick for container sizing and css object-fit to produce the effect. I've used the technique before and it works well across IE, FF and modern WebKit implementations though some of those might require some vendor specific prefixes to be added.

Related

How can I add spacing between these progress bar titles?

THIS IS A RESPONSIVE DESIGN, MAKE SURE TO TURN ON TOGGLE DEVICE TOOLBAR ON YOUR BROWSER
I am trying to make a progress bar. First I want to increase the height of the transparent black background. I can't find a way to do that. I am confused. And secondly, I want to add spacing and align the 2nd and 3rd text properly.
/* progress bar */
.center {
height: 300px;
width: 100%;
position: absolute;
left: 50%;
margin-top: 140px;
transform: translate(-50%, -50%);
padding: 20px;
background-color: rgba(0, 0, 0, 0.678);
box-shadow: 0 2px 60px rgba(0, 0, 0, .5);
border-radius: 10px;
color: white;
}
.center #progress{
margin: 0px;
padding: 0;
color: #fff;
text-transform: uppercase;
letter-spacing: 8px;
border-radius: 20px;
height: auto;
background-color: rgba(0, 0, 0, 0);
}
.skillbar{
box-sizing: border-box;
width: 100%;
margin: 20px 0;
}
/* skillbar languages */
.skillbar-html p{
color: #fff;
text-transform: uppercase;
margin: 0 0 10px;
padding: 0;
font-weight: bold;
letter-spacing: 3px;
}
.skillbar-html p:nth-child(2){
float: right;
position: relative;
top: -30px;
}
.skillbar-css p{
color: #fff;
text-transform: uppercase;
margin: 0 0 10px;
padding: 0;
font-weight: bold;
letter-spacing: 3px;
}
.skillbar-css p:nth-child(2){
float: right;
position: relative;
top: -30px;
}
.skill_percentage{
background-color: #262626;
padding: 4px;
box-sizing: border-box;
border: 1px solid #0fffb7;
border-radius: 6px;
}
.skill_level{
background-color: #0fffb7;
width: 100%;
height: 10px;
border-radius: 6px;
}
<section>
<div class="center">
<h1 id="progress">Progress</h1>
<div class="skillbar-html">
<p>HTML</p>
<p>90%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 90%;"></div>
</div>
<div class="skillbar-css">
<p>CSS</p>
<p>70%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 80%;"></div>
</div>
<div class="skillbar-javascript">
<p>JavaScript</p>
<p>50%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 50%;"></div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</section>
</section>
You can take advantage of the <br> element in your HTML.
Line break and tab elements can be used when you need a little more control over how the browser renders the text. The <BR> element is used to force a line break.
-W3.org
/* progress bar */
.center {
height: 300px;
width: 100%;
position: absolute;
left: 50%;
margin-top: 140px;
transform: translate(-50%, -50%);
padding: 20px;
background-color: rgba(0, 0, 0, 0.678);
box-shadow: 0 2px 60px rgba(0, 0, 0, .5);
border-radius: 10px;
color: white;
}
.center #progress{
margin: 0px;
padding: 0;
color: #fff;
text-transform: uppercase;
letter-spacing: 8px;
border-radius: 20px;
height: auto;
background-color: rgba(0, 0, 0, 0);
}
.skillbar{
box-sizing: border-box;
width: 100%;
margin: 20px 0;
}
/* skillbar languages */
.skillbar-html p{
color: #fff;
text-transform: uppercase;
margin: 0 0 10px;
padding: 0;
font-weight: bold;
letter-spacing: 3px;
}
.skillbar-html p:nth-child(2){
float: right;
position: relative;
top: -30px;
}
.skillbar-css p{
color: #fff;
text-transform: uppercase;
margin: 0 0 10px;
padding: 0;
font-weight: bold;
letter-spacing: 3px;
}
.skillbar-css p:nth-child(2){
float: right;
position: relative;
top: -30px;
}
.skill_percentage{
background-color: #262626;
padding: 4px;
box-sizing: border-box;
border: 1px solid #0fffb7;
border-radius: 6px;
}
.skill_level{
background-color: #0fffb7;
width: 100%;
height: 10px;
border-radius: 6px;
}
<section>
<div class="center">
<h1 id="progress">Progress</h1>
<br>
<div class="skillbar-html">
<p>HTML</p>
<p>90%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 90%;"></div>
</div>
<br>
<div class="skillbar-css">
<p>CSS</p>
<p>70%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 80%;"></div>
</div>
<br>
<div class="skillbar-javascript">
<p>JavaScript</p>
<p>50%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 50%;"></div>
</div>
</div>
</div>
</div>
</div>
</section>
The Height: - I noticed a fixed height of 300px, and that you were centering the parent div by using margins and translations in your CSS. I went ahead and removed those margins and translations, also removed your absolute positioning. You can adjust your fixed height of 300px to expand the grey background. For this example, I made it 100 view height.
/* progress bar */
.center {
height: 100vh;
width: 100%;
padding: 20px;
position: relative;
background-color: rgba(0, 0, 0, 0.678);
box-shadow: 0 2px 60px rgba(0, 0, 0, .5);
border-radius: 10px;
color: white;
}
.center #progress{
margin: 0px;
padding: 0;
color: #fff;
text-transform: uppercase;
letter-spacing: 8px;
border-radius: 20px;
height: auto;
background-color: rgba(0, 0, 0, 0);
}
.skillbar{
box-sizing: border-box;
width: 100%;
margin: 20px 0;
}
/* skillbar languages */
.skillbar-html p{
color: #fff;
text-transform: uppercase;
margin: 0 0 10px;
padding: 0;
font-weight: bold;
letter-spacing: 3px;
}
.skillbar-html p:nth-child(2){
float: right;
position: relative;
top: -30px;
}
.skillbar-css p{
color: #fff;
text-transform: uppercase;
margin: 0 0 10px;
padding: 0;
font-weight: bold;
letter-spacing: 3px;
}
.skillbar-css p:nth-child(2){
float: right;
position: relative;
top: -30px;
}
.skill_percentage{
background-color: #262626;
padding: 4px;
box-sizing: border-box;
border: 1px solid #0fffb7;
border-radius: 6px;
}
.skill_level{
background-color: #0fffb7;
width: 100%;
height: 10px;
border-radius: 6px;
}
<section>
<div class="center">
<h1 id="progress">Progress</h1>
<br>
<div class="skillbar-html">
<p>HTML</p>
<p>90%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 90%;"></div>
</div>
<br>
<div class="skillbar-css">
<p>CSS</p>
<p>70%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 80%;"></div>
</div>
<br>
<div class="skillbar-javascript">
<p>JavaScript</p>
<p>50%</p>
<div class="skill_percentage">
<div class="skill_level" style="width: 50%;"></div>
</div>
</div>
</div>
</div>
</div>
</section>
If I understood properly, what you want to increase the height is for that black bar containing your actual progress bar, right? If that's the case, I think this should work:
.skill-percentage {
height: x (here you place how much height you want);
}
That should give you the height that you want.
And, in order to add the spacing, you can take advantage of CSS padding or margin, depending on what you exactly need.
I'll give you a small snippet here so you can see exactly what I mean. Note that I modified a bit your HTML to fit what you wanted to do, but this may not be necessary on your original file.
/* progress bar */
* {
margin: 0;
padding: 0;
}
.center {
height: 500px;
width: 100%;
background-color: rgba(0, 0, 0, 0.678);
color: white;
}
.center #progress{
margin: 0px;
padding: 0;
color: #fff;
text-transform: uppercase;
letter-spacing: 8px;
border-radius: 20px;
height: auto;
background-color: rgba(0, 0, 0, 0);
}
.skillbar{
box-sizing: border-box;
width: 100%;
margin: 0;
}
/* skillbar languages */
.text-container {
display: flex;
width: 100%;
justify-content: space-between;
}
.text-container p {
padding: 0 40px; /* this is the one that changes the position of your text. Be carefull, you don't want this to change the position too much, just a bit, if you need to change the full position, better try something like grid, or modifying the flex */
}
.skillbar-html {
display: flex;
flex-direction: column;
justify-content: center;
}
.skillbar-html p {
margin: 10px;
}
.skillbar-html > div {
margin: 10px;
}
.skillbar-css {
display: flex;
flex-direction: column;
justify-content: center;
}
.skillbar-css p {
margin: 10px;
}
.skillbar-css > div {
margin: 10px;
}
.skillbar-javascript {
display: flex;
flex-direction: column;
justify-content: center;
}
.skillbar-javascript p {
margin: 10px;
}
.skillbar-javascript > div {
margin: 10px;
}
.skill_percentage{
height: 20px; /* this is the one that changes your height, now it's changing nothing, but you can modify the height by changing this value */
background-color: #262626;
padding: 4px;
box-sizing: border-box;
border: 1px solid #0fffb7;
border-radius: 6px;
}
.skill_level{
background-color: #0fffb7;
width: 100%;
height: 10px;
border-radius: 6px;
}
<section>
<div class="center">
<h1 id="progress">Progress</h1>
<div class="skillbar-html">
<div class="text-container">
<p>HTML</p>
<p>90%</p>
</div>
<div class="skill_percentage">
<div class="skill_level" style="width: 90%;">
</div>
</div>
</div>
<div class="skillbar-css">
<div class="text-container">
<p>CSS</p>
<p>70%</p>
</div>
<div class="skill_percentage">
<div class="skill_level" style="width: 80%;">
</div>
</div>
</div>
<div class="skillbar-javascript">
<div class="text-container">
<p>JavaScript</p>
<p>50%</p>
</div>
<div class="skill_percentage">
<div class="skill_level" style="width: 50%;">
</div>
</div>
</div>
</div>
</section>

React/CSS: why does my <p> tag move its parent <div> on mobile?

I am writing a React app that's mobile first. MY div alignment seemed to be normal on Firefox Dev Tools iPhone screen but when I launched my app, the alignment is erratic. Seems like it's due to the height of the <p> element or its # of lines. I know this because it was happening on PC too but I fixed it by setting the p element to a fixed height. If someone has any ideas as to why it is happening and if there is a fix, please let me know, it'll be greatly appreciated!
Here is screenshot of iPhone mobile:
iphone mobile frontend
Here is screenshot of PC on Mozilla Firefox Webdev tools:
PC Mozilla Firefox
Here is my css:
.card {
background-color: #ffffff;
width: 110px;
height: 110px;
border-radius: 15px;
border: solid 3px #dddddd;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
display: inline-block;
margin: 10px 10px;
}
.card:hover{
border: outset 4px #dddddd;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 12px 40px 0 rgba(0, 0, 0, 0.19);
cursor: grab;
}
.card:active{
cursor: grabbing;
}
.card img{
margin-left: auto;
margin-right: auto;
margin-top:10%;
width: 50%;
height: 50%;
}
.card span{
background-color:limegreen;
width: 80px;
height: 80px;
margin-left: auto;
margin-right: auto;
}
.card-p{
width: 80%;
height: 40px;
display: inline-block;
font-family: 'Poppins', sans-serif;
color: #45505c;
margin: 0 auto;
font-size: 75%;
overflow: hidden;
}
.card-container {
margin-left: auto;
margin-right: auto;
text-align: center;
}
.container{
margin-top: 50px;
width: 80%;
}
.container h2{
text-align: center;
font-size: 1.5em;
color: rgb(255, 255, 255);
width: 80%;
margin-left: auto;
margin-right: auto;
font-family: Georgia, 'Times New Roman', Times, serif;
}
Here is my React JSX
return (
<div className='container'>
<h2>{props.questionData.question}</h2>
<div className='card-container'>
{
props.questionData.options.map((option,index)=>(
<div className={'card'} onClick={()=>handleClick(props.questionData.question,option.text)} key={index}>
<img src={option.iconPath} alt='icon'/>
<p className='card-p'>{option.text}</p>
</div>))
}
</div>
</div>
);
Edit: People are asking for pure html, here it is copied from Firefox inspect element...Also included the stylesheet in the same snippet. Thanks in advance!
.card {
background-color: #ffffff;
width: 110px;
height: 110px;
border-radius: 15px;
border: solid 3px #dddddd;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
display: inline-block;
margin: 10px 10px;
}
.card:hover{
border: outset 4px #dddddd;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 12px 40px 0 rgba(0, 0, 0, 0.19);
cursor: grab;
}
.card:active{
cursor: grabbing;
}
.card img{
margin-left: auto;
margin-right: auto;
margin-top:10%;
width: 50%;
height: 50%;
}
.card span{
background-color:limegreen;
width: 80px;
height: 80px;
margin-left: auto;
margin-right: auto;
}
.card-p{
width: 80%;
height: 40px;
display: inline-block;
font-family: 'Poppins', sans-serif;
color: #45505c;
margin: 0 auto;
font-size: 75%;
overflow: hidden;
}
.card-container {
margin-left: auto;
margin-right: auto;
text-align: center;
}
.container{
margin-top: 50px;
width: 80%;
}
.container h2{
text-align: center;
font-size: 1.5em;
color: rgb(255, 255, 255);
width: 80%;
margin-left: auto;
margin-right: auto;
font-family: Georgia, 'Times New Roman', Times, serif;
}
<div class="container">
<h2>Great! What type of property are you refinancing?</h2>
<div class="card-container">
<div class="card">
<img src="/static/media/0-1.400fe52e.svg" alt="icon">
<p class="card-p">Single Family Home</p>
</div>
<div class="card">
<img src="/static/media/0-2.f2e4dfe1.svg" alt="icon">
<p class="card-p">Town Home</p>
</div>
<div class="card">
<img src="/static/media/0-3.bc78fdb6.svg" alt="icon">
<p class="card-p">Condominium</p>
</div>
<div class="card">
<img src="/static/media/0-4.5d3ec9ae.svg" alt="icon">
<p class="card-p">Multi Family Home</p>
</div>
<div class="card">
<img src="/static/media/0-5.7a491458.svg" alt="icon">
<p class="card-p">Manufactured or Mobile Home</p>
</div>
</div>
</div>
The issue is that you are using inline-block for the cards.
Since there are two lines of text, the inline-block elements line up on the baseline of the text. You'll notice that the bottom line of text is aligned on the ones up higher.
A simple fix is to add these lines to your .card-container
.card-container {
...
display: flex;
flex-flow: row wrap;
justify-content: center;
}
The display mode is ignored for child items of a flex container. You can remove the display: inline-block from the .card if you go with this solution.
Something else to note about inline-block is that it doesn't ignore white space. When using inline-block elements, these two snippets will produce different results.
.box {
display: inline-block;
background: #ccc;
width: 32px;
height: 32px;
}
<div>
<div class="box"></div>
<div class="box"></div>
</div>
<div>
<div class="box"></div><div class="box"></div>
</div>

How to make a centered section clickable?

I simply want to make a centered section clickable. I used margin auto to center my section but now the margins are clickable too. Should I use flex-box or something to center the section so that there's no more margin or there is an other way? What's the best practice here?
<main>
<a href="#">
<section>
<div class="content">
<h2>some stuff</h2>
<h1>title</h1>
<img src="img/arrow.svg" alt="arrow" width="30">
</div>
</section>
</a>
</main>
section {
width: 400px;
height: 400px;
margin: 0 auto 100px auto;
}
Here's a JSFiddle : Clickable centered section
I've another solution for you. Just add the following code to your css. You can try this.
a {
display: block;
height: fit-content;
width: fit-content;
margin: 0 auto 100px auto;
}
a {
display: block;
height: fit-content;
width: fit-content;
margin: 0 auto 100px auto;
}
section {
border-radius: 10px;
width: 400px;
height: 400px;
position: relative;
box-shadow: 0 1px 3px rgba(85, 85, 85, 0.25), 0 1px 2px rgba(0,0,0,0.12);
transition: all 0.5s cubic-bezier(.25,.8,.25,1);
}
section:hover {
box-shadow: 0 14px 28px rgba(85, 85, 85, 0.25), 0 10px 10px rgba(0,0,0,0.10);
}
section.logofolio {
background-color: #3D75E3;
}
section .content {
position: absolute;
bottom: 0;
padding: 0 0 100px 100px;
}
section h1 {
font-family: 'Archivo Black', sans-serif;
font-weight: bold;
font-size: 3rem;
color: #FFFFFF;
padding-top: 10px;
}
section h2 {
font-family: 'Roboto Mono', monospace;
font-weight: 400;
font-size: 0.8rem;
color: #FFFFFF;
}
section img {
padding-top: 10px;
}
<main class="work">
<p style="text-align: center">
As you can see the margins are clickable too!
</p>
<a href="#">
<section class="logofolio">
<div class="content">
<h2>some stuff</h2>
<h1>Title</h1>
<img src="img/arrow.svg" alt="arrow" width="30">
</div>
</section>
</a>
</main>
Here's my solution for you. I used absolute positioning to center the div. I separated my code using comments. You can check that. Hope it will be helpful.
section {
border-radius: 10px;
width: 1000px;
height: 400px;
/*Edited portion starts*/
position: absolute;
left: 50%;
/* margin: 0 auto 100px auto; */
/*Edited portion ends*/
transform: translateX(-50%);
box-shadow: 0 1px 3px rgba(85, 85, 85, 0.25), 0 1px 2px rgba(0,0,0,0.12);
transition: all 0.5s cubic-bezier(.25,.8,.25,1);
&:hover {
box-shadow: 0 14px 28px rgba(85, 85, 85, 0.25), 0 10px 10px rgba(0,0,0,0.10);
}
.content {
position: absolute;
bottom: 0;
padding: 0 0 100px 100px;
h1 {
font-family: 'Archivo Black', sans-serif;
font-weight: bold;
font-size: 3rem;
color: #FFFFFF;
padding-top: 10px;
}
h2 {
font-family: 'Roboto Mono', monospace;
font-weight: 400;
font-size: 0.8rem;
color: #FFFFFF;
}
img {
padding-top: 10px;
}
}
}
section.logofolio {
background-color: #3D75E3;
}
<main class="work">
<a href="#">
<section class="logofolio">
<div class="content">
<h2>some stuff</h2>
<h1>Title</h1>
<img src="img/arrow.svg" alt="arrow" width="30">
</div>
</section>
</a>
</main>

Align image and 2 text lines

I'm trying to align this div so that the image appear first and then the 2 lines after, however i cant seem to make it align proberly.
#overview {
width: 350px;
height: 500px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
#overview #header-collapse {
height: 50px;
width: 100%;
background-color: #ff8217;
color: #fff;
font-size: 15px;
line-height: 50px;
white-space: nowrap;
-moz-border-radius: 0px;
-webkit-border-radius: 3px 3px 0px 0px;
border-radius: 3px 3px 0px 0px;
text-align: center;
}
#overview #body-list {
background: #fff;
height:450px;
overflow-y: auto;
width: 100%;
border-radius: 0px 0px 3px 3px;
-webkit-border-radius: 0px 0px 3px 3px;
border-radius: 0px 0px 3px 3px;
}
#overview #body-list a {
text-decoration:none;
}
.list-item:hover {
background-color: rgba(82, 82, 82, .1);
}
.list-item {
border-bottom: 1px solid rgba(82, 82, 82, .2);
height: 80px;
width: 100%;
padding-left: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
position: relative;
}
.list-item p {
margin: 0px;
}
.list-item #header-title {
color: #954500;
font-size: 20px;
font-weight: 400;
}
.list-item #subtitle {
color: rgb(82, 82, 82);
opacity: 0.6;
font-size: 13px;
}
.list-item #list-image {
height: 60px;
width: 60px;
background-color: #000;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
}
<div id="overview">
<div id="header-collapse">
<h4>
Oversigt
</h4>
</div>
<div id="body-list">
<a href="#">
<div class="list-item">
<div id="list-image"></div>
<p id="header-title">Title</p>
<p id="subtitle">Subtitle</p>
</div>
</a>
</div>
</div>
The easiest, and most modern way is to use flexbox.
With this method, the image circle and the text will both be centered vertically, so you don't have to worry about it later.
Place your header-title and subtitle inside of a div.
<div class="list-titles">
<p id="header-title">Title</p>
<p id="subtitle">Subtitle</p>
</div>
Then add the following to your .list-item class:
.list-item {
display: flex;
align-items: center;
}
(I also added margin-right: 10px; to your image so it looks better xD)
Here is a working JSFiddle
Add float:left to that div.
.list-item #list-image {float:left;}
Working JSFIDDLE
Wrap the two titles in a new DIV, then define that new DIV and the DIV of the image as inline-blocks, like this: (you'll have to finetune the margins for distances)
#overview {
width: 350px;
height: 500px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
#overview #header-collapse {
height: 50px;
width: 100%;
background-color: #ff8217;
color: #fff;
font-size: 15px;
line-height: 50px;
white-space: nowrap;
-moz-border-radius: 0px;
-webkit-border-radius: 3px 3px 0px 0px;
border-radius: 3px 3px 0px 0px;
text-align: center;
}
#overview #body-list {
background: #fff;
height:450px;
overflow-y: auto;
width: 100%;
border-radius: 0px 0px 3px 3px;
-webkit-border-radius: 0px 0px 3px 3px;
border-radius: 0px 0px 3px 3px;
}
#overview #body-list a {
text-decoration:none;
}
.list-item:hover {
background-color: rgba(82, 82, 82, .1);
}
.list-item {
border-bottom: 1px solid rgba(82, 82, 82, .2);
height: 80px;
width: 100%;
padding-left: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
position: relative;
}
.list-item p {
margin: 0px;
}
.list-item #header-title {
color: #954500;
font-size: 20px;
font-weight: 400;
}
.list-item #subtitle {
color: rgb(82, 82, 82);
opacity: 0.6;
font-size: 13px;
}
.list-item #list-image {
height: 60px;
width: 60px;
background-color: #000;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
}
#list-image, #title-wrapper {
display: inline-block;
}
<div id="overview">
<div id="header-collapse">
<h4>
Oversigt
</h4>
</div>
<div id="body-list">
<a href="#">
<div class="list-item">
<div id="list-image"></div>
<div id="title-wrapper">
<p id="header-title">Title</p>
<p id="subtitle">Subtitle</p>
</div>
</div>
</a>
</div>
</div>

Making the outer wrapper div height equal to content

First of all i know it would be better to have the css in a external file, but this is just for testing. i've created a banner which include several columns with images. In order to make this responsive i'm trying to use percentages. However i've come to a issue regarding the wrapper div, when applying auto height. It seem to just make it 100% instead of the same height as the actual content? How can i make the wrapper div same height as the content(images)?
JSFiddle link: http://jsfiddle.net/z41nknL3/
<head>
<style>
.wrapper {
width: 100%;
height: auto;
}
.item {
float: left;
}
.double-size {
width: 66.6666%;
height: auto;
}
.normal-size {
float: left;
width: 33.3333%;
height: auto;
display: inline-block;
}
.double-size .column-big {
box-sizing:border-box;
width: 100%;
height: auto;
padding: 0px 2px 0px 0px;
}
.normal-size .column-small-1 {
box-sizing:border-box;
width: 100%;
height: 50%;
padding: 0px 0px 2px 2px;
}
.normal-size .column-small-2 {
box-sizing:border-box;
width: 100%;
height: 50%;
padding: 2px 0px 0px 2px;
}
.column-content {
height: 100%;
position: relative;
overflow: hidden;
}
.column-content .meta-info-doub {
box-sizing:border-box;
position: absolute;
height: auto;
width: 100%;
bottom:0;
right: 0;
padding: 40px;
}
.column-content .meta-info-norm {
box-sizing:border-box;
position: absolute;
height: auto;
width: 100%;
bottom:0;
right: 0;
padding: 20px;
}
.title-double {
font-family: 'Open Sans', sans-serif;
font-size: 20px;
line-height: 1.65;
background: #161616;
background: rgba(22, 22, 22, 0.5);
color: #fff;
display: inline;
padding: 4px 0;
margin: 0;
-webkit-box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
text-transform: uppercase;
}
.title-normal {
font-family: 'Open Sans', sans-serif;
font-size: 17px;
line-height: 1.65;
background: #161616;
background: rgba(22, 22, 22, 0.5);
color: #fff;
display: inline;
padding: 4px 0;
margin: 0;
-webkit-box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
box-shadow: 7px 0 0 rgba(22, 22, 22, 0.5), -7px 0 0 rgba(22, 22, 22, 0.5);
text-transform: uppercase;
}
.date-double {
font-family: 'Open Sans', sans-serif;
display: inline;
color: #fff;
font-size: 11px;
text-shadow: 0 1px 0 #222;
text-transform: uppercase;
margin-bottom: 11px;
display: block;
}
.date-normal {
font-family: 'Open Sans', sans-serif;
display: inline;
color: #fff;
font-size: 11px;
text-shadow: 0 1px 0 #222;
text-transform: uppercase;
margin-bottom: 11px;
display: block;
}
.column-content .content-image{
height: auto;
width: 100%;
background-size: 100%;
display:block;
-moz-transition: all .5s;
-webkit-transition: all .5s;
transition: all .5s;
}
.column-content .content-image:hover {
-moz-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
#media all and (max-width: 768px) {
.normal-size {
float: none;
width: 100%;
margin-top: 3px;
}
.double-size {
float: none;
width: 100%;
}
}
</style>
</head>
<body>
<div class="wrapper">
<div class="item double-size">
<div class="column-big">
<div class="column-content">
<img src="http://blognewswp.gotheme.net/wp-content/uploads/2014/08/shutterstock_190029455_supersize-640x400.jpg" href="#" id="img-zoom" class="content-image">
<div class="meta-info-doub">
<h3 class="date-double">23. Oktober 2015</h3>
<h3 class="title-double">Post 1</h3>
</div>
</div>
</div>
</div>
<div class="item normal-size">
<div class="column-small-1">
<div class="column-content">
<img src="http://blognewswp.gotheme.net/wp-content/uploads/2014/08/shutterstock_190029455_supersize-640x400.jpg" href="#" id="img-zoom" class="content-image">
<div class="meta-info-norm">
<h3 class="date-double">23. Oktober 2015</h3>
<div class="info-title"><h3 class="title-normal">Post 2</h3></div>
</div>
</div>
</div>
<div class="column-small-2">
<div class="column-content">
<img src="http://blognewswp.gotheme.net/wp-content/uploads/2014/08/shutterstock_190029455_supersize-640x400.jpg" href="#" id="img-zoom" class="content-image">
<div class="meta-info-norm">
<h3 class="date-double">23. Oktober 2015</h3>
<div class="info-title"><h3 class="title-normal">Post 3</h3></div>
</div>
</div>
</div>
</div>
</div>
</body>
Try :
.wrapper {
position:absolute;
}
And I have updated the JSFiddle to remove some unnecessary divs:
http://jsfiddle.net/z41nknL3/1/
P.S.: the background: red; on .wrapper is to show you its height.
Try to remove height: 100% from .column-content