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>
Related
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>
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>
The #itemcontent div is not stretching to the size of its contents. How can i get the #item-content div to extend past its current position without setting the height in pixels to keep it wrapping!
Here is a codepen:
http://codepen.io/Malvooo/pen/GJeVxW
Stack Snippet below:
#import url(http://fonts.googleapis.com/css?family=Open+Sans:300,400,700);
* {
margin: 0;
padding: 0;
}
body {
background: #222;
font-family: 'Open Sans', sans-serif;
}
#item {
margin-bottom: 2%;
margin-top: 8px;
transition: opacity 1s;
-webkit-transition: opacity 1s;
width: 300px;
}
#triangle {
border-bottom: 12px solid #3399cc;
border-left: 12px solid transparent;
border-right: 12px solid transparent;
border-top: 12px solid transparent;
margin: 0 auto;
width: 0;
}
#item h1 {
background: #3399cc;
color: #fff;
font-size: 140%;
font-weight: 300;
padding: 20px 0;
text-align: center;
}
#item-content {
background: #f0f0f0;
padding: 0 4%;
}
#item-left {
background: #f0f0f0;
float: left;
padding: 5px 0;
width: 50%;
}
#item-content h2 {
color: #555;
font-size: 95%;
font-weight: 600;
padding: 5px 0;
padding-left: 10px;
text-align: left;
width: 100%;
}
#item-right {
background: #f0f0f0;
float: right;
padding: 5px 0;
width: 50%;
}
#item-content h3 {
color: #555;
font-size: 95%;
font-weight: 300;
padding: 5px 0;
text-align: left;
width: 100%;
}
#item-content h4 {
background: #3399cc;
color: #fff;
font-size: 100%;
font-weight: 300;
padding: 5px 0;
text-align: center;
}
<body>
<div id="item">
<div id="triangle"></div>
<h1>Assault Rifle</h1>
<div id="item-content">
<div id="item-left">
<h2>Type</h2>
<h2>Stacksize</h2>
</div>
<div id="item-right">
<h3>Weapon</h3>
<h3>1</h3>
</div>
<h4>Weapon Stats</h4>
<div id="item-left">
<h2>Fire Mode</h2>
<h2>Attack Rate</h2>
<h2>Damage</h2>
<h2> </h2>
<h2> </h2>
<h2> </h2>
<h2>Recoil</h2>
<h2>Range</h2>
<h2>Capacity</h2>
</div>
<div id="item-right">
<h3>Full Automatic</h3>
<h3><i>Unknown</i></h3>
<h3>Head: 100</h3>
<h3>Chest: 61</h3>
<h3>Arms: 11</h3>
<h3>Legs: <i>unknow</i></h3>
<h3>Medium-Severe</h3>
<h3>250 ~ 400m</h3>
<h3>30</h3>
</div>
<h4>Ammunition</h4>
<div id="item-img">
<img src="images/5.56_Rifle_Ammo_icon.png" height="50px" width="50px" style="margin: 2.85%;">
<img src="images/Explosive_5.56_Rifle_Ammo_icon.png" height="50px" width="50px" style="margin: 2.85%;">
<img src="images/HV_5.56_Rifle_Ammo_icon.png" height="50px" width="50px" style="margin: 2.85%;">
<img src="images/Incendiary_5.56_Rifle_Ammo_icon.png" height="50px" width="50px" style="margin: 2.85%;">
</div>
<h4>Crafting</h4>
<div id="item-left">
<h2>Craftable</h2>
<h2>Known By Default</h2>
<h2>Time To Craft</h2>
</div>
<div id="item-right">
<h3>Yes</h3>
<h3>No</h3>
<h3>180s</h3>
</div>
</div>
</div>
</body>
Try this one:
#item-content div {
background: #f0f0f0;
height: 100%;
}
This will make sure the entire item content will wrapp all the content.
Edit:
Just add overflow: hidden; to #item-content and this will solve your problem:
#item-content {
background: #f0f0f0;
padding: 0 4%;
overflow: hidden;
}
See working fiddle
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.
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