My footer background color is not displaying...
What am I missing?
The test site is http://qtest.pw
I am adding extra words as requested... Don't know what else to say.. So I will keep typing until it says its ok
HTML
<div id="FooterWrapper">
<div id="FooterDiv1"><img src="images/ada-logo.png" alt="American dental Association - Helmich Dental">
</div>
<div id="FooterDiv2">
</div>
<div id="FooterDiv3">
</div>
<div id="FooterDiv4">
</div>
CSS
#FooterWrapper {
clear: both;
margin: auto;
max-width: 1232px;
display: block;
padding-left: calc((100% - 1232px)/2);
padding-right: calc((100% - 1232px)/2);
background-color: #000;
}
#FooterDiv1 {
clear: both;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv2 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv3 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv4 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
Try adding this to clear the floats on the items contained with in;
#FooterWrapper:before,
#FooterWrapper:after {
content:"";
display:table;
}
#FooterWrapper:after {
clear:both;
}
This is because your #FooterWrapper does not contain float properties but your child divs have a float: left; property assigned.
So, if you add the below properties to #FooterWrapper than you can get the background color as expected.
#FooterWrapper {
width: 100%;
float: left;
}
Hope, this helps you.
Try this:-
body {
margin:0;
padding:0;
font: 100%/1.3 arial,helvetica,sans-serif;
background:#3F6A8A;
}
#FooterWrapper {
clear: both;
margin: auto;
max-width: 1232px;
display: block;
padding-left: calc((100% - 1232px)/2);
padding-right: calc((100% - 1232px)/2);
}
#FooterDiv1 {
clear: both;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv2 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv3 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv4 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
<div id="FooterWrapper">
<div id="FooterDiv1"><img src="https://i.ytimg.com/vi/s9dbAfjlrks/maxresdefault.jpg" alt="American dental Association - Helmich Dental">
</div>
<div id="FooterDiv2">
</div>
<div id="FooterDiv3">
</div>
<div id="FooterDiv4">
</div>
Try this:-
body {
margin:0;
padding:0;
font: 100%/1.3 arial,helvetica,sans-serif;
background:#3F6A8A;
}
#FooterWrapper {
clear: both;
margin: auto;
max-width: 1232px;
display: block;
padding-left: calc((100% - 1232px)/2);
padding-right: calc((100% - 1232px)/2);
background-color:#000;
}
#FooterDiv1 {
clear: both;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv2 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv3 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
#FooterDiv4 {
clear: none;
float: left;
margin-left: 0;
width: 19%;
display: block;
padding: 2%;
}
<div id="FooterWrapper">
<div id="FooterDiv1"><img src="images/ada-logo.png" alt="American dental Association - Helmich Dental">
</div>
<div id="FooterDiv2">
</div>
<div id="FooterDiv3">
</div>
<div id="FooterDiv4">
</div>
Found another solution.. Tell me if I am on the right track.. Or are there errors or bad code? It seems to work well
http://qtest.pw
Thanks to all that contributed!!!
HTML
<div id="FooterWrapper">
<div id="FooterDiv1"><img src="images/ada-logo.png" alt="American dental Association - Helmich Dental" class="imagecenter">
</div>
<div id="FooterDiv2">
</div>
<div id="FooterDiv3">
</div>
<div id="FooterDiv4">
</div>
</div>
CSS
#FooterWrapper {
clear: both;
margin: auto;
overflow: hidden;
max-width: 1232px;
display: block;
padding-left: calc((100% - 1232px)/2);
padding-right: calc((100% - 1232px)/2);
background-color: #000;
}
#FooterDiv1 {
clear: both;
margin-left: 1.6%;
width: 23.4%;
display: block;
}
#FooterDiv2 {
clear: none;
width: 25%;
display: block;
}
#FooterDiv3 {
clear: none;
width: 25%;
display: block;
}
#FooterDiv4 {
clear: none;
margin-right: 1.6%;
width: 23.4%;
display: block;
}
If you add min-height: 170px your background color will display. Right now your footer doesn't have any height in the DOM so no color showing.
Related
I aligned the objects using display: flex; Now I have tried to put the header on the same line using text-align: justify; and display: block;, but it still doesn't work. What am I doing wrong. Can someone please help with this?
.pos-container {
list-style: none;
padding-top: 40px;
padding-bottom: 60px;
display: block;
}
.pos-info {
display: inline-flex;
float: left;
}
.pos-info: before {
display: block;
height: 1px;
background-color: #045d71;
content: " ";
width: 90%;
margin: 0 auto;
}
.pos-image {
border-radius: 3px;
width: 47%;
height: 50%;
}
.pos-container i {
font-size: 180%;
color: #07a0c3;
margin-top: 150px;
margin-left: 40px;
display: block;
}
.pos-info h3 {
display: inline-block;
font-size: 110%;
text-align: left;
margin-left: 40px;
float: left;
column-width: auto;
}
.pos-content {
display: flex;
text-align: justify;
margin-top: 69px;
float: right;
margin-left: -118px;
margin-bottom: 80px;
}
.pos-content: after {
display: block;
height: 0.1px;
background-color: #045d71;
content: " ";
width: 90%;
margin: 0 auto;
}
<div class="row">
<ul class="pos-container">
<li class="pos-info">
<img class="pos-image" src="resources/img/cashier2.jpg" alt="pos picture">
<i class="ion-arrow-left-b"></i>
<h3>POS Software</h3>
<p class="pos-content">We offer a payment solution which functions on the cloud. It gives you access to your inventory, expenses, sales and operations from wherever you are located. It is designed for simplicity, so your employees won’t need any special training to use
the software. In case of a bad connection to the internet, the payment system will still work normally and would update every captured payment and transaction, once the connection is restored. A cheap and affordable solution for any type of restaurant,
bar or lounge with available payment plans.
</p>
</li>
</ul>
</div>
.wrapper {
display: flex;
}
.content {
margin-left: 40px;
}
h2 {
margin: 0;
}
<div class="wrapper">
<img src="http://via.placeholder.com/400x400" />
<div class="content">
<h2>Title</h2>
<p>Text</p>
</div>
</div>
I want my inline images to automatically resize with browser size and at the same time it should be inline with the header too. I have already tried solution given here but it is not working for me.
Here is my code:
#header_title {
font-weight: bolder;
text-align: center;
}
#header_photo {
display: none;
}
.floatingimage {
float: right;
max-width: 100%;
height: auto;
}
#media all and (max-width: 1024px) {
#header_title {
margin-left: 10%;
min-width: 67%;
max-width: 77%;
display: inline-block;
vertical-align: top;
position: relative;
}
#header_photo {
display: inline-block;
vertical-align: top;
max-width: 20%;
height: auto;
}
}
<header>
<div id="header_title">
<h1>Title h1</h1>
<h3>Title h3</h3>
</div>
<aside id="header_photo">
<img class="floatingimage" src="http://www.planwallpaper.com/static/images/Awesome-Nature-Background.jpg" width="100px" height="100px" />
</aside>
</header>
You find this code on jsfiddle here.
NOTE: I am using Firefox 53.0.3(32-bit)
I slightly modified your HTML and CSS. I add flex display and image height related to width.
HTML code:
<header>
<div id="header_title">
<h1>Title h1</h1>
<h3>Title h3</h3>
</div>
<aside id="header_photo">
<img class="floatingimage" src="http://www.planwallpaper.com/static/images/Awesome-Nature-Background.jpg"/>
</aside>
CSS code:
header {
display: flex;
}
#header_title
{
font-weight: bolder;
text-align: center;
}
#header_photo
{
display: none;
max-width: 100%;
height: auto;
align-self: center;
}
#header_photo img {
width: 100%;
height: auto;
max-height: 120px;
}
.floatingimage
{
float: right;
}
#media all and (max-width: 1024px)
{
#header_title
{
margin-left: 10%;
min-width: 67%;
max-width: 77%;
display: inline-block;
vertical-align: top;
position: relative;
}
#header_photo
{
display: inline-block;
vertical-align: top;
max-width: 20%;
height: auto;
}
}
You check it on fiddle here
You have sized the image using inline-styling; that is the main problem. You can do two 2 things:
add the width and height to the floatingimage class
OR
create a new class e.g. .wh100, with width:100px; and height:100px; and use a second class with the .floatingimage in your html e.g img class="floatingimage wh100"
In either option, remember to REMOVE the inline styling from the html!!
Then your images should size appropriately.
Give that a whirl
RE-EDIT: (back on computer - sigh..).. here you go.. the fiddle i posted a while ago with the header narrowed to 75%.
header {
width: 75%;
height: auto;
margin: 0 auto;
padding: 0;
}
#header_title {
font-weight: bolder;
text-align: center;
max-width: 80%;
}
#header_photo {
/*display: none;*/
margin: 0;
padding: 0;
max-width: 20%;
height: auto;
float: right;
}
.floatingimage {
position: relative;
display: none;
}
.wh100 {
width: 100px;
height: 100px;
}
#media all and (max-width:480px){
#header_photo {
margin-top: 8%!important;
}
}
#media all and (max-width:1024px) {
#header_title,
#header_photo img {
margin: 0;
padding: 0;
top: 2%;
display: inline!important;
vertical-align: middle!important;
}
#header_title {
max-width: 80%;
position: relative;
float: left;
}
#header_photo {
margin-top: 4%;
max-width: 20%;
position: relative;
float: right;
}
#header_photo img {
position: relative;
max-width: 100%;
height: auto;
}
}
<header>
<div id="header_title">
<h1>Title h1</h1>
<h3>Title h3</h3>
</div>
<aside id="header_photo">
<img class="floatingimage wh100" src="http://www.planwallpaper.com/static/images/Awesome-Nature-Background.jpg" />
</aside>
</header>
New fiddle
I'm trying to make a simple game, and I've run into few problems I can't seem to solve:
I can't center vertically floated elements (.stat and .clickable).
Total height of all elements should fit exactly into screen height, however it goes beyond it.
Images differ a bit in their width depending on value I give them (at my screen they look the same at 32% or 29%, but on 30% upper one has slightly wider (and a bit blurry) right border).
Height property of img elements has no effect.
Here's my code (Images are 450px wide squares):
* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
background-color: #e6e6e6;
}
.statsBar,
.buttons {
color: #333333;
font-family: Impact, Charcoal, sans-serif;
text-transform: uppercase;
background-color: #bfbfbf;
height: 13%;
}
#score {
float: left;
margin-left: 5%;
}
#hp {
float: right;
margin-right: 5%;
}
.stats:after {
content: "";
display: block;
clear: both;
}
.clickable {
float: left;
width: 29.33%;
margin: 1%;
padding: 1%;
background: #f2f2f2;
}
.game {
width: 50%;
height: 100%;
text-align: center;
margin: auto;
background-color: #999999;
}
img {
width: 32%;
display: block;
margin: auto;
}
#enemyHand {
transform: rotate(180deg);
margin-top: 5%;
}
#playerHand {
margin-bottom: 5%;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src='game.js'></script>
</head>
<body>
<div class="game">
<div class="statsBar">
<p id="score" class="stat">score: 0</p>
<p id="hp" class="stat">hp: 3</p>
</div>
<div class="hands">
<img id="enemyHand" src="paper.png">
<img id="playerHand" src="scissors.png">
</div>
<div class="buttons">
<a id="paper" class="clickable" onclick="document.getElementById('playerHand').src='paper.png'">Paper</a>
<a id="rock" class="clickable" onclick="document.getElementById('playerHand').src='rock.png'">Rock</a>
<a id="scissors" class="clickable" onclick="document.getElementById('playerHand').src='scissors.png'">Scissors</a>
</div>
</div>
</body>
</html>
I don't know what you mean with your first question. However I can help you with the second. I made some small changes to your code, but I don't have the image. Look at the code bellow. The game container now is set to max-height: 100%; and height: 100vh; that should help. (100vh means the hole page. I also made body overflow: hidden;, because I think scrolling isn't necessary. I made the buttons container to the bottom of the page.
* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
background-color: #e6e6e6;
overflow:hidden;
}
.statsBar,
.buttons {
color: #333333;
font-family: Impact, Charcoal, sans-serif;
text-transform: uppercase;
background-color: #bfbfbf;
height: 13%;
}
.buttons {
bottom: 0;
clear:both;
}
#score {
float: left;
margin-left: 5%;
}
#hp {
float: right;
margin-right: 5%;
}
.stats:after {
content: "";
display: block;
clear: both;
}
.clickable {
float: left;
width: 29.33%;
margin: 1%;
padding: 1%;
background: #f2f2f2;
}
.game {
width: 50%;
max-height: 100%;
height: 100vh;
text-align: center;
margin: auto;
background-color: #999999;
}
img {
height: 50%;
display: block;
margin: auto;
}
#enemyHand {
transform: rotate(180deg);
margin-top: 5%;
}
#playerHand {
margin-bottom: 5%;
}
For the third question, we don't have the images...
For the height property try display: block; and no width then. Check your classed normally it should work.
I hope I helped you !!!
You can take advantage of flexbox in this case (note the scroll is generated by the snippet's viewport height, ideally it wouldn't even overflow, but if it did, overflow: auto is set just to handle it, you can comment it though based on your benefit):
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
height: 100%;
background-color: #e6e6e6;
}
.statsBar,
.buttons {
color: #333333;
font-family: Impact, Charcoal, sans-serif;
text-transform: uppercase;
background-color: #bfbfbf;
height: 13%;
display: flex;
flex-flow: row wrap;
justify-content: space-around;
align-items: center;
}
.hands {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
/* comment if content will never overflow */
overflow-x: auto;
}
.buttons {
display: flex;
flex-flow: row wrap;
justify-content: center;
align-items: center;
}
.clickable {
float: left;
width: 29.33%;
margin: 1%;
padding: 1%;
background: #f2f2f2;
}
.game {
width: 50%;
height: 100%;
/*text-align: center;*/
margin: auto;
background-color: #999999;
display: flex;
flex-flow: column wrap;
justify-content: center;
}
img {
width: 32%;
display: block;
margin: auto;
}
/*#score {
float: left;
margin-left: 5%;
}*/
/*#hp {
float: right;
margin-right: 5%;
}*/
/*.stats:after {
content: "";
display: block;
clear: both;
}*/
/*#enemyHand {
transform: rotate(180deg);
margin-top: 5%;
}*/
/*#playerHand {
margin-bottom: 5%;
}*/
<div class="game">
<div class="statsBar">
<p id="score" class="stat">score: 0</p>
<p id="hp" class="stat">hp: 3</p>
</div>
<div class="hands">
<img id="enemyHand" src="paper.png">
<img id="playerHand" src="scissors.png">
</div>
<div class="buttons">
<a id="paper" class="clickable" onclick="document.getElementById('playerHand').src='paper.png'">Paper</a>
<a id="rock" class="clickable" onclick="document.getElementById('playerHand').src='rock.png'">Rock</a>
<a id="scissors" class="clickable" onclick="document.getElementById('playerHand').src='scissors.png'">Scissors</a>
</div>
</div>
Please check this code. I solve your question 1 and 2. I don't understand about your image issue.
* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
background-color: #e6e6e6;
}
.statsBar,
.buttons {
display: table;
color: #333333;
font-family: Impact, Charcoal, sans-serif;
text-transform: uppercase;
background-color: #bfbfbf;
height: 13%;
width: 100%;
}
#score,
#hp{
display: table-cell;
vertical-align: middle;
padding: 10px;
}
#score {
/*float: left;
margin-left: 5%;*/
text-align: left;
}
#hp {
/*float: right;
margin-right: 5%;*/
text-align: right;
}
.stats:after {
content: "";
display: block;
clear: both;
}
.clickable {
/*float: left;*/ /*Float sould not use here */
display: table-cell;
width: 29.33%;
/*margin: 1%;
padding: 1%;*/
border: 5px solid #bfbfbf;
vertical-align: middle;
background: #f2f2f2;
}
.game {
width: 50%;
height: 100%;
text-align: center;
margin: auto;
background-color: #999999;
}
img {
width: 32%;
display: block;
margin: auto;
}
#enemyHand {
transform: rotate(180deg);
margin-top: 5%;
}
#playerHand {
margin-bottom: 5%;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src='game.js'></script>
</head>
<body>
<div class="game">
<div class="statsBar">
<p id="score" class="stat">score: 0</p>
<p id="hp" class="stat">hp: 3</p>
</div>
<div class="hands">
<img id="enemyHand" src="http://placehold.it/450x450">
<img id="playerHand" src="http://placehold.it/450x450">
</div>
<div class="buttons">
<a id="paper" class="clickable" onclick="document.getElementById('playerHand').src='paper.png'">Paper</a>
<a id="rock" class="clickable" onclick="document.getElementById('playerHand').src='rock.png'">Rock</a>
<a id="scissors" class="clickable" onclick="document.getElementById('playerHand').src='scissors.png'">Scissors</a>
</div>
</div>
</body>
</html>
I want to make the top margin of a h2 class bigger then it is now. I tried applying margin-top and padding, but they both didn't work. When i use margin-top on the h2portfolio class, the margin-top of section 1 (so a totally different section) changes.
U can see this on interlaser.webovo.nl. I need to change the margin of the orange 'Portfolio' h2, so class "h2portfolio".
The html i used to build that section:
<h2 class="h2portfolio">Portfolio</h2>
<div id="portfolio1">
<h2 class="h2portfolio1">Feesten</h2>
<img class="portfolio1"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
<div id="portfolio2">
<h2 class="h2portfolio2">Kunst</h2>
<img class="portfolio2"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
<div id="portfolio3">
<h2 class="h2portfolio3">Overige</h2>
<img class="portfolio3"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
the css i used:
.h2portfolio {
background-color: white;
text-align: center;
color: #F16C20;
}
#portfolio1 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
#portfolio2 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
#portfolio3 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
.portfolio1 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
.portfolio2 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
.portfolio3 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
I have made the updates in the answer.
1 : make a separate div for lazershow contents
2 : make a separate div for portfolio title & its contents and then give margin(as per your need) to the portfolio div which satisfy your requirements.
.lazershow{
background:white;
height:200px;
}
.portfolio_div{
border:thin black solid;
}
.h2portfolio {
background-color: white;
text-align: center;
color: #F16C20;
margin-top:10%; /*Give margin as per your need*/
}
#portfolio1 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
#portfolio2 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
#portfolio3 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
.portfolio1 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
.portfolio2 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
.portfolio3 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
<div class="lazershow">
LazerShow Div
</div>
<div class="portfolio_div">
<h2 class="h2portfolio">Portfolio</h2>
<div id="portfolio1">
<h2 class="h2portfolio1">Feesten</h2>
<img class="portfolio1"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
<div id="portfolio2">
<h2 class="h2portfolio2">Kunst</h2>
<img class="portfolio2"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
<div id="portfolio3">
<h2 class="h2portfolio3">Overige</h2>
<img class="portfolio3"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
</div>
I have given margin-top to h2portfolio class.
Here is JSFiddle
Hope this helps.
Just Add margin-top: 100px; and padding-bottom:15px; style in .h2portfolio class as you need.
.h2portfolio {
background-color: white;
text-align: center;
color: #F16C20;
margin-top: 100px;
padding-bottom:15px;
}
#portfolio1 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
#portfolio2 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
#portfolio3 {
width: 33.33%;
float: left;
text-align: center;
display: block;
}
.portfolio1 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
.portfolio2 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
.portfolio3 {
margin-top: 7.5%;
margin-right: 7.5%;
margin-left: 7.5%;
margin-bottom: 7.5%;
width: 85%;
}
<h2 class="h2portfolio">Portfolio</h2>
<div id="portfolio1">
<h2 class="h2portfolio1">Feesten</h2>
<img class="portfolio1"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
<div id="portfolio2">
<h2 class="h2portfolio2">Kunst</h2>
<img class="portfolio2"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
<div id="portfolio3">
<h2 class="h2portfolio3">Overige</h2>
<img class="portfolio3"src="http://interlaser.webovo.nl/wp-content/uploads/2017/01/cropped-cropped-maxresdefault-300x204.jpg">
</div>
Just add to your class ".h2portfolio":
.h2portfolio {
background-color: white;
text-align: center;
color: #F16C20;
margin-top: 100px;
padding-bottom:15px;
//line new added
float: left;
width: 100%;
margin-top: 100px;
}
I'm creating a match list using ul and li tags. However i want to set some spans to a fixed width and then apply rest of the spans to the equal rest width. In my example there are 3 spans with a width 10px. I want the first team and second team classes to fill the rest of the width how can i do this using percentages?
.match-list {
padding: 0;
list-style-type: none;
}
.list-item {
list-style: none;
margin-bottom: 9px;
}
.list-item .image-col {
width: 50px;
float: left;
}
.list-item .empty-col {
width: 50px;
text-align: right;
float: left;
}
.list-item .time-col {
width: 50px;
text-align: center;
float: left;
}
.list-item .first-team {
text-align: right;
float: left;
}
.list-item .second-team {
float: left;
text-align: left;
}
<div>
<ul class="match-list">
<li class="list-item">
<span class="image-col">img</span>
<span class="first-team">First team</span>
<span class="time-col">12:00</span>
<span class="second-team">Second team</span>
<span class="empty-col">empty</span>
</li>
</ul>
</div>
You could use flexbox
CSS
.list-item {
list-style: none;
margin-bottom: 9px;
display:flex;
direction:row;
}
.list-item .first-team {
order:1;
flex-grow:2;
text-align: right;
float: left;
background:#d7d7d7;
text-align:center;
}
.list-item .second-team {
order:2;
flex-grow:2;
float: left;
text-align: left;
background:#a7a7a7;
text-align:center;
}
Check it on Codepen
If you can remove those float properties, you could use some table tricks on your layout, like this:
.match-list {
padding: 0;
list-style-type: none;
}
.list-item {
list-style: none;
margin-bottom: 9px;
}
/*added stuff*/
.list-item {
display: table;
width: 100%;
}
.list-item > span {
display: table-cell;
}
.list-item .image-col {
width: 50px;
}
.list-item .empty-col {
width: 50px;
text-align: right;
}
.list-item .time-col {
width: 50px;
text-align: center;
}
.list-item .first-team {
text-align: center;
}
.list-item .second-team {
text-align: center;
}
<div>
<ul class="match-list">
<li class="list-item">
<span class="image-col">img</span>
<span class="first-team">First team</span>
<span class="time-col">12:00</span>
<span class="second-team">Second team</span>
<span class="empty-col">empty</span>
</li>
</ul>
</div>
you can do this with css calc():
.list-item .first-team {
width: calc(50% - 150px);
text-align: right;
float: left;
}
.list-item .second-team {
width: calc(50% - 150px);
float: left;
text-align: left;
}
example: http://jsfiddle.net/qqu2448n/