Set one span fixed width and other rest width - html

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/

Related

how to center image based navigation bar with image embedded button?

I would like to have my navigation bar elements centered.
As of now, I have got three <li> elements inside <ul>.
Two based on images and one is text
Can anyone help me get this centered or point out why it is not working for me ?
I have ignored the JavaScript as my focus is on indentation.
<div class = "navigationBar">
<ul>
<li><button id="back" onclick="myFunction()"><img src="./img/previous.png"></button> </li>
<li><div id ="currentFileString"> <h2>2/4<h2></div></li>
<li><button id="next"><img src="./img/next.png"></button></li>
</ul>
</div>
CSS:
#header{
font-family: "Al Bayan";
}
.jumbotron{
padding-top: 10px;
padding-bottom: 0px;
text-align: center;
}
.navigationBar{
height: 80px;
padding-bottom: 10px;
align-content: center;
margin : 0 auto;
display: inline;
text-align: center;
vertical-align: center;
}
button{
border: none;
background: none;}
ul {
display: inline;
margin: 0 auto;
/*text-align: center;*/
list-style-type: none;
padding: 10px;
text-align: center;
}
li {
display: inline-block;
text-align:center;
}
.table-striped
{
width: 60%;
}
#tableLeft{
float :left;
width: 40%;
}
#tableright{
float: right;
width: 40%;
}
The answer below. Try this
#header{
font-family: "Al Bayan";
}
.jumbotron{
padding-top: 10px;
padding-bottom: 0px;
text-align: center;
}
.navigationBar{
height: 80px;
padding-bottom: 10px;
align-content: center;
margin : 0 auto;
/*display: inline;*/
text-align: center;
vertical-align: center;
}
button {
border: none;
background: none;}
ul {
display: inline;
margin: 0 auto;
/*text-align: center;*/
list-style-type: none;
padding: 10px;
text-align: center;
}
li {
display: inline-block;
text-align:center;
}
.table-striped
{
width: 60%;
}
#tableLeft{
float :left;
width: 40%;
}
#tableright{
float: right;
width: 40%;
}
<div class = "navigationBar">
<ul>
<li><button id="back" onclick="myFunction()"><img src="https://cdn4.iconfinder.com/data/icons/flat-black/128/prev.png" width="20"></button> </li>
<li><div id ="currentFileString"> <h2>2/4<h2></div></li>
<li><button id="next"><img src="https://cdn4.iconfinder.com/data/icons/flat-black/512/next.png" width="20"></button></li>
</ul>
</div>

Icon and padding

bob i {font-size: 10px} shows a neat horizontal block, and the name titles are aligned. When I increase the font-size for bob i to 30px, then the two spans are not neatly horizontally aligned anymore. The icon is not that big so why does it make the bob span block blow up? Is it possible to have bob i {font-size: 40px} and keep everything neatly horizontally aligned?
.joe span
{
display: block;
padding: 20px;
text-align: left;
}
.pete
{
width: 30%;
float: left;
background-color: green;
}
.bob
{
width: 10%;
float: left;
background-color: blue;
}
.bob i {
font-size: 30px;
padding-left: 10%;
}
<div class="wrapper"><div class="joe"><span class="pete">Pete</span>
<span class="bob">Bob<i class="icon">#</i></span>
</div></div>
Just change these class property
.joe span {
display: flex;
align-items: center;
padding: 20px;
}
.bob i {
font-size: 40px;
padding-left: 10%;
line-height: 0;
}
.joe span {
display: flex;
align-items: center;
padding: 20px;
}
.pete
{
width: 30%;
float: left;
background-color: green;
}
.bob
{
width: 10%;
float: left;
background-color: blue;
}
.bob i {
font-size: 40px;
padding-left: 10%;
line-height: 0;
}
<div class="wrapper"><div class="joe"><span class="pete">Pete</span>
<span class="bob">Bob<i class="icon">#</i></span>
</div></div>

Place logo and text in the same line

I am trying to create the header part of my page. In the header, I want to have an image (a logo) on the left side, and a "logged in as ..." on the right side of the same line.
The problem that I have is that the logo simply overrides the "logged in as" text, so only logo stays visible on the page, and there is no text.
Here is the code:
<div class="header">
<span class="myLogo"/>
<span class="user">
Logged in as " target="_blank">${user}</a>
</span>
</div>
CSS:
.myLogo {
display: inline;
float: left;
margin-left: 10px;
margin-top: 30px;
content:url("myLogo.png");
}
.user {
text-align: right;
white-space: nowrap;
display: inline;
float: left;
margin-top: 20px;
margin-right: 30px;
font-size: large;
}
.header {
display: inline-block;
}
How can I have my logo on the left side of the page, and my text on the right side of the page, but in the same line?
I think you should set
display: inline-block;
for both class or change class user to
float: right
Use this CSS.
.myLogo {
display: inline;
float: left;
margin-left: 10px;
margin-top: 30px;
content:url("myLogo.png");
}
.user {
white-space: nowrap;
display: inline;
float: right;
margin-top: 20px;
margin-right: 30px;
font-size: large;
}
.header {
display: inline-block;
width: 100%;clear:both;
}
Why do you use content instead of an <img> tag?
Anyway, what I could suggest for you is to use flexbox:
.header{
display: flex;
align-items: baseline;
}
.user{
margin-left: auto;
}
You can try this method
HTML:
<div>
<img class="myLogo" src = "myLogo.png"/>
</div>
<div class="user">
Logged in as <a target="_blank">${user}</a>
</div>
CSS:
.myLogo {
display: inline;
float: left;
margin-left: 10px;
margin-top: 30px;
height: 10px;
width: auto;
}
.user {
text-align: right;
white-space: nowrap;
display: inline;
float: left;
margin-top: 20px;
margin-right: 30px;
font-size: large;
}
.header {
display: inline-block;
}
You have to make 2 changes
remove inline block for .header class
Change float:right under .user class
.myLogo {
display: inline;
float: left;
margin-left: 10px;
content:url("https://1.bp.blogspot.com/-NknV6HIVxKc/V06_WraBJEI/AAAAAAAAJWc/QwJMGxKHaywCIf2QHOLD-YwFQdn8VDaVgCLcB/s320/chelsea-logo.PNG");
width:50px;
height:50px;
}
.user {
text-align: right;
white-space: nowrap;
display: inline;
float: right;
margin-right: 30px;
font-size: large;
}
<div class="header">
<span class="myLogo"></span>
<span class="user">
Logged in as <a target="_blank">hai</a>
</span>
</div>

Div Wrapper Background color not displaying

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.

CSS 3 Column Layout Collapses Under Large Screen Width

I have the following section of code for by CSS 3-Column Layout. However under a very large screen width, the first column collapses (around 2000px). I added the code for the navigation, as the links could be impacting the display of the columns.
CSS and HTML
#container
{
width: 75%;
margin-left: auto;
margin-right: auto;
}
header h1
{
font-size: 40px;
float: left;
font-weight: 100;
}
header h1 a
{
text-decoration: none;
color: black;
}
header nav
{
float: right;
}
header nav ul
{
list-style-type: none;
margin: 0;
vertical-align: middle;
line-height: normal;
float: right;
z-index: 999;
position: relative; /* add this */
}
header nav ul li
{
line-height: 15px;
float: left;
padding: 45px;
font-size: 22px;
font-weight: 100;
text-align: center;
}
header nav ul li a
{
color: black;
text-decoration: none;
}
.content
{
margin-left: auto;
margin-right: auto;
width: 75%;
font-size: 20px;
line-height: 50px;
}
#media screen and (max-width: 1160px) {
header h1
{
float: none;
text-align: center;
font-size: 36px;
}
header nav
{
width: 100%;
margin-right: 20px;
}
header nav ul
{
float: none;
text-align: center;
}
header nav ul li
{
width: 100%;
box-sizing: border-box;
text-align: center;
padding: 25px;
}
}
.col {
float: left;
}
.col-1-3 {
width: 33%
}
.col-1-3 a {
font-weight: bold;
}
<div id="container">
<header>
<h1><strong>Henry</strong><span id="notbold">+Applications</span></h1>
<nav>
<ul>
<li id="me"><div id="meanimation">Home</div></li>
<li id="project"><div id="projectanimation">Project</div></li>
<li id="contact"><div id="contactanimation">Contact</div></li>
</ul>
</nav>
</header>
</div>
<br><br><br><br>
<div class="content">
<div class="col col-1-3"><p><em>Email</em></p><p>This is the quickest way to contact me!</p>
The Fastest Way
</div>
<div class="col col-1-3"><p><em>Phone</em></p><p>You can get in touch with me with a phone call or text!</p>
Text Me
</div>
<div class="col col-1-3"><p><em>Public Profile</em></p><p>Right now, I only have a Google+ profile, but I am sure to expand soon.</p>
Google+<br>
StackOverflow
</div>
</div>
I added overflow: hidden; to .content and I got the good result.
.content {
margin-left: auto;
margin-right: auto;
width: 75%;
font-size: 20px;
line-height: 50px;
overflow: hidden;
}