Space before left tab - css

I have been stuck on a problem here. This is what I designed my app in html and css. The problem is indicated with red circle in lower left corner i.e. the space before the left tab. I am unable to remove this space. This is neither padding nor margin but I don't know what it is.
The code for tab is:
html
<ul id="bottomTabs">
<li>Player</li>
<li>Reciters</li>
</ul>
css
ul {
margin: 0 ;
bottom: 0 ;
left: 0 ;
padding: 0;
}
li {
list-style-type: none;
bottom: 0 ;
left: 0 ;
margin-left:1em ;
}
#bottomTabs {
width: 100%;
bottom: 0px;
display: table;
position: fixed;
table-layout: fixed;
text-align: center;
}
#bottomTabs li {
width: 47.5%;
height: auto;
align : center;
display: table-cell;
padding-left: 1.5%;
vertical-align: bottom;
}
#bottomTabs a {
display: block;
color: #ffffff;
min-height: 100%;
padding: 4px 10px;
background-color: #222;
border-radius: 0 0 0 0;
}

You have padding-left: 1.5% on both of your li elements. You only need it for the second one. You can create a new class/id just for the second list item. Have your HTML as:
<ul id="bottomTabs">
<li>Player</li>
<li id="padded">Reciters</li>
</ul>
And CSS:
#bottomTabs li {
width: 47.5%;
height: auto;
align : center;
display: table-cell;
vertical-align: bottom;
}
#padded{
padding-left: 1.5%;
}
DEMO: http://jsfiddle.net/cuzZC/1/

Give a class for the first li and give padding 0..
.padd
{
padding:0 !important;
}
<ul id="bottomTabs">
<li class="padd" >Player</li>
<li>Reciters</li>
</ul>

try this one,
#bottomTabs li:first-child {
width: 47.5%;
height: auto;
align : center;
display: table-cell;
padding-left: 0;
vertical-align: bottom;
}
http://jsfiddle.net/K9jq7/

padding-left: 1.5% is causing this effect.
The first li doesn't need any padding, just add
#bottomTabs li:first-child {
padding-left: 0;
}
or you could remove the padding-left from #bottomTabs li and add
#bottomTabs li:last-child {
padding-left: 1.5%;
}
I would suggest using the first-child pseudo class since it's better supported.
http://www.quirksmode.org/css/selectors/

Related

Need to Center my CSS Menu

I need help centering my CSS menu. Not sure why it isn't centered. I played around with the padding but it didn't change anything really. I know you just can't center it like you can with HTML though.
Here is the CSS:
Here is the page:
Thank you!
-Mike
Try adding margin:auto in the css menu
#cssmenu {
background: #000000;
height: 44px;
position: relative;
width: 595px;
margin: auto;
}
FIDDLE
Add margin: 0 auto; to #CssMenu
#cssmenu {
position: relative;
height: 44px;
background: #000000;
width: 595px;
margin: 0 auto;
}
#cssmenu > ul {
position: relative;
display: block;
background: #000000;
height: 32px;
width: 100%;
z-index: 500;
text-align: center; /*add this to center your li itens*/
white-space: nowrap; /*add this if you dont want brake the 'HISTORY' link in another line*/
#cssmenu > ul > li {
display: inline-block; /*you must remove float:left; and add change display to inline-block to display your li items side by side*/
vertical-align: top; /*add this to make you li itens align by top*/
position: relative;
padding: 0;
}

Responsive / Relative Positioning Background Image

Issue I'm having is the background image on the anchor as a before element needs to move with the text as you resize your screen.
I need the background image to maintain it's position ( e.g left: 20px;) with the text as you resize your screen.
Here is my CSS:
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
ul li {
float: left;
width: 50%;
}
ul li a {
display: block;
padding: 15px 20px;
text-align: center;
text-decoration: none;
font-weight: bold;
position: relative;
color: #717171;
}
ul li a:before {
background: url(http://graphicclouds.com/wp-content/uploads/img/73-google-style-icons-thumb.jpg) no-repeat -11px -26px;
content: '';
display: block;
width: 34px;
height: 33px;
position: absolute;
top: 10px;
}
.link-1:before {
left: 20px;
}
.link-2:before {
left: 0px;
}
Here is a working example: http://jsfiddle.net/2KHS6/
All suggestions welcome
New version:
http://jsfiddle.net/2KHS6/5/
Hope it fills your needs. You might want to set a min-width to avoid problems with small screens though. I did this basically:
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
ul li {
display: inline-block;
width: 50%;
margin: 10px 0;
/* So things don't get crazy */
min-width: 160px;
/* center the child, the <a> */
text-align: center;
}
ul li a {
display: inline-block;
text-decoration: none;
font-weight: bold;
color: #717171;
/* Should be the same height as the img so it stays centered */
line-height: 33px;
}
ul li a:before {
background: url(http://graphicclouds.com/wp-content/uploads/img/73-google-style-icons-thumb.jpg) no-repeat -11px -26px;
content: '';
display: block;
width: 34px;
height: 33px;
position: absolute;
/* position the image at the left of the a. There are many methods to do this actually */
margin: 0 0 0 -50px;
}

How to push footer below content and display inline?

This question is a duplicate, but there was only one answer (not accepted or rated), almost no discussion, and the OP did not report back if it solved the problem. My css uses the suggestion, and it does not solve my problem, which I believe is the same.
I have a nav column floated to the left, and a content block (section) floated left against the nav bar. Then I have a footer section (this is html5). I am trying to create a footer nav that is inline.
The footer nav appears below the nav column, but to the left of the text (which extends past the nav column). Also, it appears in block format, not inline.
The html is roughly:
<nav>
<ul>
<li><a>...</a></li>
..
..
</ul>
</nav>
<section>
...text...
</section>
<footer>
<ul>
<li><a>...</a></li>
..
..
</ul>
</footer>
And the css is roughly:
nav {
float: left;
..
..
}
section {
float: left;
..
..
}
footer {
clear: both;
}
footer li {
display: inline;
}
Here is an example.
http://jsfiddle.net/abalter/NdExx/2/
You have several CSS issues that need to be fixed.
you use a lot of absolute/relative positioning without real need.
you don't specify vendor specific when they are needed.
you have an extra closing bracelet in your CSS (in the end).
you have a double declaration (its harmless, but annoying).
BTW, if you use that fixed CSS you will see that the clear:both; suddenly works.
(it didn't work before because the text-section was absolutely positioned)
also: I would recommend you to enclose the & text-section in one div, thus forcing the <footer> to always be below them even without clearing.
about your inline problem in the footer, although the li elements are set to display:inline; all of them contains divs, so in the end, they will behave like block elements.
as an easy fix, I changed the footer li selector in the end of the CSS to footer *, but you should specify exactly what you want to be inline.
so, here's a Fiddle to demonstrate the changes.
Fixed CSS (+Vendor specifics, -typos, -double declaration)
#background-image
{
background: url(http://www.arielbalter.com/BuzzJoy/img/green_and_roasted_half_and_half.jpg);
width: 100%;
top: 0;
left: 0;
opacity: 0.6;
position: fixed;
background-repeat: repeat-y;
padding: 0;
margin: 0;
}
header
{
width: 100%;
padding: 0;
margin: 0;
}
#buzz-joy-logo
{
width: 100%;
height: auto;
top: 0%;
position: relative;
z-index: 2;
display: block;
padding: 0;
margin: 0 auto 0 auto;
}
nav
{
padding: 0;
margin: 0 0 0 15%;
float: left;
}
nav li
{
display: inline;
}
.nav-link
{
position: relative;
width: 10em;
height: 5.3em;
background-image: url(http://www.arielbalter.com/BuzzJoy/img/CoffeeCupNoSteam.png);
display: block;
-moz-background-size: 100% 100%;
-o-background-size: 100% 100%;
-webkit-background-size: 100% 100%;
background-size: 100% 100%;
text-align: center;
margin: 0 0 1em 0;
padding: 0;
text-decoration: none;
}
.nav-link:hover
{
color: DarkGoldenRod;
}
.nav-cup-image
{
height: 100px;
width: auto;
padding: 0;
margin: 0;
}
.nav-text
{
position: relative;
color: Yellow;
font-size: 1.5em;
text-align: center;
font-family: "GillSansUltraBoldCondensedRegular", sans-serif;
font-weight: 100;
margin: 0% 13% 0 0;
padding: 0.6em 0em 10em 0;
}
.nav-text:hover
{
color: DarkGoldenRod;
}
#nav-list
{
list-style-type: none;
padding: 0;
}
.text-section
{
width: 40%;
background-color: GoldenRod;
background-color: rgb(188, 121, 0);
background-color: #BC7900;
opacity: 0.9;
padding: 0 2em 0 1em;
margin: 1% 0 0 0;
float: left;
}
.text-section h1
{
font-family: "GillSansUltraBold", sans-serif;
font-size: 2em;
margin: 0 0 0.2em 0;
padding: 0;
}
.text-section h2
{
font-family: "OpenSansExtraBold", sans-serif;
font-size: 1.8em;
margin: 0.4em 0 0em 0;
padding: 0;
}
.text-section p
{
font-family: "OpenSans", sans-serif;
font-size: 1em;
padding: 0;
margin: 0 0 0.3em 0;
}
footer
{
clear: both;
}
footer *
{
display: inline;
}
In your example you just need to set the .text-section to:
position: relative;
and the footer goes to the bottom like you want.
Otherwise your generic code will basically do what you're looking for. Here's a quick pen showing the concept: Example Pen

CSS: Fitting div height into another inclusive padding

As seen in the picture, I practically have a div of defined width 100% but no defined height, but rather the height is defined to match the contents with a percentage of top and bottom padding.
The problem is I want to have some kind of navigation buttons on the right side, and they must be aligned perfectly in the vertical middle.
I have included a Fiddle of what I did, but it doesn't show in the middle in all cases.
What can be an optimal solution.
HTML
<div class="title">Title
<ul id="bullets">
<li></li>
<li></li>
<ul>
</div>
CSS
.title {
width:100%;
background:#365F95;
background-size: contain;
font-size:130%;
color:#FFF;
padding:5% 0;
text-align:center;
position:relative;
}
.title ul {
position:absolute;
right: 0;
top: 0%;
}
.title ul li {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 10px;
background: #FFF;
box-shadow: inset 0 1px 3px black, 0 0 1px 1px #202020;
margin: 0 2px;
}
http://jsfiddle.net/HJLEe/2/
take a look at this fiddle The idea is vertically align list
position: absolute;
top: 50%;
margin-top: - half-height;
Not the best solution, but it works.
HTML:
<div class="title">Title
<ul id="bullets">
<li></li>
<li></li>
<ul>
</div>
CSS:
.title {
width:100%;
background:#365F95;
background-size; cover;
font-size:130%;
color:#FFF;
padding:5% 0;
text-align:center;
}
.title ul {
position:relative;
float: right;
margin-top: 0px;
}
.title ul li {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 10px;
background: #FFF;
box-shadow: inset 0 1px 3px black, 0 0 1px 1px #202020;
margin: 0 2px;
}
JSFIDDLE
try use position relative in your ul class
.title ul {
position: relative;
}
jsfiddle.net
try this css
.title ul {
position: absolute;
right: 0;
top: 0%;
padding-top: inherit;
margin: 0;
}
Try setting a margin in percentage. Like this...
.title ul {
position:absolute;
right: 0;
top: 0%;
vertical-align :middle;
margin-top : 5%;
}
Another option using vertical-align:middle and the helper pseudo element to hold the height.
Demo: http://jsfiddle.net/HJLEe/13/
Essential additions to the code:
.title ul {
position:absolute;
right: 0;
top: 0;
bottom: 0;
}
/* style of LIs not changed */
.title ul:before {
content: '';
display: inline-block;
height: 100%; /* makes the effective line height equal to the height of the container */
vertical-align: middle; /* align the vertical center with the vertical middle of the text, including our bullets */
}

how to align navigation horizontally and center it, with responsive CSS preferably

How to center navigation horizontally inside the div? The CSS should be responsive preferably.
HTML:
<nav id="centermenu">
<ul>
<li>Business</li>
<li>Specialities</li>
<li>Contact us</li>
</ul>
</nav>
well, the css was, and changed the left: 50% to 25%, nada. hope this was enough
#centermenu {
float: left;
width: 100%;
text-align: center;
border-bottom: 2px solid #011;
background: #ffe;
overflow: hidden;
position: relative;
}
#centermenu ul {
float: left;
clear: left;
position: relative;
list-style: none;
left: 50%;
display: block;
text-align: center;
}
#centermenu ul li {
display: inline;
text-align: center;
margin: 1em;
padding: 1em;
}
Make sure your browser is not rendering in quirks mode. You should have a DOCTYPE specified on the first line of the HTML file to render in standards mode:
<!DOCTYPE html>
In standards mode, this works (tested and working for me):
#centermenu {
width: 100%;
text-align: center;
border-bottom: 2px solid #011;
background: #ffe;
overflow: hidden;
position: relative;
}
#centermenu ul {
list-style: none;
display: block;
margin: 0 auto;
text-align: center;
}
#centermenu ul li {
display: inline;
text-align: center;
margin: 1em;
padding: 1em;
}
#centermenu {
display:block;
width:100%;
text-align:center;
}
#centermenu > ul {
display:inline-block;
text-align:left;
overflow:auto;
}
#centermenu > ul > li {
float:left;
}
ul {
display: block;
margin: 0 auto;
}
u need to specified the width for ul, if you use margin: 0 auto; no need float: left; or left: 50%
#centermenu ul {
margin: 2 auto;
display: block;
width: 600px;
}
or make ul display inline;
#centermenu ul {
display: inline;
}

Resources