Live site.
The <li> items in the far right Twitter feed have excess spacing between them and I can't figure out why- there aren't any weird padding or margin issues that I can find.
The site is Wordpress, but here is the rendered HTML:
<li>
<h2>Recent Tweets</h2>
<div id="twitter-feed">
<ul>
<li>
RT #LollyDaskal: regret is often the result of too many excuses. #leadfromwithin #leadership</li>
<li>
What you do in small doses becomes big doses in your life.</li>
<li>
RT #ThisIsSethsBlog: Seth's Blog: Two kinds of unique http://t.co/1TJ1Vuf9</li>
</ul>
</div><!-- end twitter-feed -->
<div class="forward-link">
<p><span style="color:#b8bf33">Follow #Growing_Edge</span></p>
</div><!-- end forward-link -->
</li>
And the CSS
#landing-brief #twitter-feed {
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 75%;
line-height: 1.5;
color: #333333;
margin-left: -28px;
}
#landing-brief #twitter-feed ul li {
padding-bottom: 5px;
height: 200px;
}
#landing-brief .forward-link {
position: absolute;
left: 0;
bottom: 0;
}
Any ideas as to what's causing this?
There are two lines that are the culprits here. Both of these specify an explicit height of 200px. I'm guessing it comes from the template you are using.
/* On line 2836 in style.css */
#landing-brief #twitter-feed ul li {
height: 200px;
padding-bottom: 5px;
}
/* On line 2814 in style.css */
#landing-brief ul li {
display: inline-block;
height: 200px;
padding-bottom: 20px;
padding-right: 20px;
position: relative;
vertical-align: top;
width: 250px;
}
To fix it, you need to override the explicit height of the li blocks to auto !important;, or remove the height of the li altogether.
How I came to this conclusion:
I used Firefox with FireBug and inspected the individual Twitter post. After disabling the 200px height on both of the style blocks, it looked correct.
Please let me know if this works :-)
#landing-brief #twitter-feed ul li {
padding-bottom: 5px;
height: 200px; <--- here is your problem.
}
Using an element inspector allows you to see where the defined styles of an element come from. and can help you spot problems like this quickly.
#landing-brief #twitter-feed ul li {
padding-bottom: 5px;
height: 50px;
}
The height:200px on #landing-brief #twitter-feed ul li is causing this. Make it something smaller or make it auto by removing the height completely.
Not sure if you are aware of this, but using the developer console to debug HTML/JS/CSS in Safari/Chrome is very useful, as you can change fields in real time and see how the browser will render them.
The height of the li's are height:200px, change to height:auto;
I'd say it's the height you gave to '#landing-brief #twitter-feed ul li'. Try this:
#landing-brief #twitter-feed ul li {
padding-bottom: 5px;
height: auto;
}
Related
i have some problems with the CSS code below. The problem is that only one of the icons are visible (#maps), guess it is some problem with the positioning? (70%?) i cant find the problem, hope that someone here can help.
Thanks in advance.
#navlist {
position: relative;
}
#navlist li {
margin: 0;
padding: 0;
list-style: none;
position: absolute;
top: 10px;
left: 70%;
}
#navlist li, #navlist a {
height: 64px;
display: block;
}
#face{
left: 0px;
width: 64px;
height: 64px;
background: url('.../imageurl') 0 0;
}
#maps{
width: 64px;
height: 64px;
background: url('.../imageurl') 0 0;
}
Html code:
<ul id="navlist">
<li id="face"></li>
<li id="maps"></li>
</ul>
there is definetly an issue with #face! Although I´m not sure if that will make it visible again because I would also need your HTML code. You gave it the attribute left:0px; (btw. you dont need to write "px" if it is 0 anyways). But the browser cant do anything with that because it doesnt know with which kind of positioning you are working! The attribute left:0; makes only sense if you have already given it either position:absolute; or position:relative;. All over all I would advise you to read more about the basic position techniques and upload you HTML for a closer look.
EDIT: Found the problem.You think #face has the attribute left:0;? You are wrong! Because #navlist li { left:70%} beats #face{left:0;} So just remove that attribute at #navlist li and add it at #maps! It will fix it! It was a cascading issue if you are want to read more about it google: CSS cascading system.
I am trying to get my nav element to center but it won't work for the older versions of Internet Explorer or Chrome. It also won't change style. How can I get this to center and change? Here is the code:
The nav:
<nav id="Nav">
Library |
Contact |
About
</nav>
The CSS
#Nav {
margin:0 auto;
font-size: 40px;
color: #22b14c;
font-family: "Papyrus";
}
There are many ways to centre elements:
Margin way:
With a set width or display: inline-block; you can use:
margin-left: auto;
margin-right: auto;
text-align way:
With a set width or display: inline-block; you can add this to the parent:
text-align: center;
Absolute way:
position: absolute;
left: 50%;
margin-left: width/2;
or
position: absolute;
left: 50%;
transform: translate(0, -50%);
Also don't worry too much about ie7 and below as the the majority of people use higher versions of ie or a different browser though this should work up until ie6
Another thing to watch out for is that you want to use a ul for your navbar. I know, from experience, that it works fine though if you ever want to add a drop-down to the navbar then it is much harder.
Use the below:
text-align: center;
instead of
margin 0 auto;
Sample Fiddle
Note: My assumption was that you did not want to specify a width. Otherwise, you can just use the margin as already stated in the other answers.
EDIT: To use the <nav> and other HTML5 tags with lower version of IE, you can use the HTML5shiv.js (by including the below script).
<script src='http://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js' type='text/javascript'></script>
margin: 0 auto; has no meaning without specifying the width.
Since it is a block element it will spread 100% across the page, try giving it a width
#Nav {
display:Block;
width:500px;
margin:0 auto;
font-size: 40px;
color: #22b14c;
font-family: "Papyrus";
}
Use:
#Nav
{
margin-left:auto;
margin-right:auto;
width: 12em;
font-size: 40px;
color: #22b14c;
font-family: "Papyrus";
}
Ok. This is really weird and I have spent countless hours in vain searching for anything similar. I will add code, but you'll need visuals as well, so I'll include a couple of cropped images to show you what I mean.
My goal: Simple. Push my horizontal nav bar in my footer about 25px below the top edge of the footer. (Footer has a static background image)
Code used: #footer ul {margin:25px}
Result: No change.
HUH? So I played with it... tried several variations, but nothing worked. NOW, I did find a workaround... used padding instead of margin... but it bothered me that margin wouldn't work so I kept trying to figure out if I messed up my code somewhere.
I used float in the body, but I cancelled it out. Validations all came out ok. So I accidentally stumbled upon Firebug (never used it before... and still don't know how) but in my aimless clicking, I noticed something odd... when I clicked onto my footer ul, a box overlapping the footer and content was highlighted. So it appeared that my margin did exist, but instead of pushing my nav list down... it kept the nav list static, and expanded into the content.
HUH? So I did a little experiment. I created a bright border around the divs in my content and footer and ul to figure out exactly what was happening. (My content section has three divs: content (floating left); sidebar (floating right); and contentWrapper that contains both).
With the borders on, I noticed that my 'outerContent' div was collapsed. A mere 20% or so of the height of the area. So after some (lengthy) research, I came up with the overflow-auto fix. And although I still don't quite understand it, it worked. The contentWrapper expanded to meet the footer, and the footer ul moved to where I wanted to.
So problem fixed, right? Well..... not exactly.
My previews did fine, so I went back in and deleted the borders so I can get on with the rest of the formatting. Only when I previewed again... the footer ul was right back where it started. At the very edge of the top of the footer.
I did the borders again... the divs seemed fine, except that the contentWrapper was now pushed slightly above the footer to allow for that margin.
Now the REALLY weird thing is that when I put the border around my footer... the ul margin works. When I take it off... the ul goes back to where it was.
What the #$#%!? Although I know of the workaround (the padding) I am worried about compounding whatever mistake I have made and repeating constantly in the future (I have to build another website after this). If someone can figure out what I did to screw things up... it would be GREATLY appreciated.
#contentWrapper {
overflow: auto;
padding: 20px 10px;
}
#content {
float: left;
width: 660px;
}
#content h1 {
padding: 0 0 20px;
}
#content h2 {
padding: 20px 0 10px;
}
#content p {
line-height: 160%;
text-align: justify;
}
#content img {
float: left;
margin-right: 10px;
}
#content ul {
line-height: 160%;
list-style: disc outside url("../images/Bullet-artsy1.png");
margin: 0 0 10px 325px;
padding: 10px 0;
}
#content .info {
margin: 5px 0 10px 250px;
}
#rightSide {
float: right;
line-height: 140%;
padding: 0 10px;
width: 220px;
}
#rightSide h2 {
margin-top: 10px;
padding-bottom: 10px;
}
#rightSide p {
font-family: Georgia,"Times New Roman",Times,serif;
font-size: 16px;
text-align: justify;
}
#rightSide img {
display: block;
margin: 5px auto;
}
#footer {
background-image: url("../images/TCS-Footer1b-plain-230px h.png");
background-repeat: no-repeat;
clear: both;
height: 230px;
}
#footer ul {
list-style: none outside none;
margin: 25px;
text-align: center;
}
#footer ul li {
display: inline;
margin: 30px 0;
}
#footer ul li a {
color: #E8FAFF;
padding: 30px;
}
#footer p {
color: #E8FAFF;
text-align: center;
}
#footer img {
bottom: -60px;
position: relative;
right: -900px;
}
The site is not active, but I've uploaded a word doc with images showing what I am talking about. This is the link to Temp Share: http://temp-share.com/show/dPf3UCobW
Thanks in advance to everyone who can perhaps show me where I went wrong.
First, to prevent your margin from disappearing, either change the margin on the #footer ul element to padding, or add one px of padding to the #footer element.
In this fiddle, we've set the padding on the #footer to 1px and reduced the height by 2px to compensate.
FIDDLE
#footer ul {
list-style: none outside none;
padding: 40px;
text-align: center;
}
or
#footer {
background-color: #DDDDDD;
background-repeat: no-repeat;
clear: both;
color: #808080;
font-size: 12px;
height: 228px;
padding: 1px;
}
looking at the css, your padding settings on the <a> tags won't work the way you expect, since by default they are aren't block elements. Add this to the css to have them padded correctly:
#footer ul li a {
display: inline-block;
}
likewise, your ul li should be inline-block.
so ...
#footer ul li {
display: inline-block;
margin: 30px 0;
}
#footer ul li a {
display: inline-block;
color: #E8FAFF;
padding: 30px;
}
Basically, just be aware that when top and bottom margins touch, including those of parent and child elements, the largest margin is used, but the margin is pushed outside the outermost element.
I tested it using firebug and working fine. If you have problem you can add !important at the end as this
#footer > ul {
margin: 13px !important;
}
And even what you would like to do is to get some margin before and or after the ul. For this you could set margin and/or padding value to your #footer.
Hope this help!
This is for future reference. I simply wanted to add the following link to compliment Dom Day's above. I am still having difficulty conceptualizing the event but between the two links, it will help me research it until I find the equivalent to an 'adjoining/collapsing margins-for-dummies' site. www.w3.org/TR/CSS2/box.html - Details near the bottom of the web page.
I'm trying to build a horizontal menu with the last item seperated and positioned right, so that a logo finds place between the last and the second last item.
Firefox, Opera (Presto) and even the dirty ones from Redmond (9.0+) render it like I would expect. But WebKit (Chrome and Safari both render it the same) takes some space after the second last item where the last item would stay without position: absolute.
<header>Logo</header>
<nav>
<ul>
<li>Home</li>
<li>Statistics</li>
<li>Data Management</li>
<li>Market Research</li>
<li>Web & Apps</li>
<li>Contact</li>
</ul>
</nav>
I display the list as table and the list items as table-cell because I want the left part of the menu (first to second last item, left to the logo) to have a fixed width while the items take the width they need for their contents. Text could change to anything. Till there, everything is alright. But if I give the last item a display: block; position: absolute, WebKit renders that gap (white in the example).
nav ul
{
display: table;
background: white; /* that's what you see in webkit */
}
nav ul li
{
display: table-cell;
}
nav ul li:last-child
{
display: block; /* "display: none;" works like I would expect */
position: absolute;
}
Here is a Fiddle.
I'm not sure if it is a bug in WebKit, because absolute positioning an element inside a table might not be default behavior. On the other hand, display: none works like I would expect. Shouldn't the space consumption be 0 in both cases?
Does anybody know of a bug in WebKit or has anyone an idea of how to prevent that gap?
Set the penultimate element "Web & Apps" to display block instead of table-cell:
nav ul li:nth-last-child(2)
{
display: block;
}
Display block fiddle
I've pushed this answer on other people, and often got the "flexbox isn't widely supported yet" response. However, here it goes again. The reason that Webkit is misbehaving is that within its implementation of display: table, the DOM is reserving space for the semantically declared cell. The easy way to implement this would be to simply break this element out into its own object, much like you'd done with the logo.
HOWEVER...
if you want to keep these semantically grouped - And why wouldn't you, they're all content, right? - you can always use the flexbox model to overcome this.
Here's a fiddle showing its use.
Here's what we change:
nav ul
{
display: box;
display: -webkit-flex;
flex-direction: row;
-webkit-justify-content: center;
-webkit-align-items: center;
-webkit-flex-direction: row;
background: white; /* that's what you see in webkit */
empty-cells: hide;
table-layout: auto;
}
nav ul li
{
flex: 1 1 auto;
-webkit-flex: 1 1 auto;
}
Now, your items properly cover the background, as it is no longer treating the last li as if it were a true table cell and still within the bounds of the table. Flexbox provides a flexible layout to fill available space. Often people see this as a solution for the "Holy Grail of Layout" problem, but its use expands way beyond just that.
So, if another "Flexbox isn't widely supported enough" response is incoming, I understand. But I'll keep proposing it as an answer on every one of these that I come across, because support is getting better every day.
A little CSS edited, take a look at please, if this what you want, Fiddle
body
{
position: relative;
background: #bbbbbb;
text-align: center;
color: white;
}
header
{
position: absolute;
top: 10px;
left: 630px;
width: 80px;
height: 60px;
line-height: 60px;
background: black;
text-transform: uppercase;
}
nav
{
position: absolute;
top: 20px;
left: 20px;
}
nav ul,
nav li
{
list-style-type: none;
margin: 0;
padding: 0;
}
nav ul
{
width: 200px;
}
nav ul li a
{
display: block;
padding: 1px;
background: #0099ff;
color: white;
text-decoration: none;
}
nav ul li a:hover
{
background: black;
}
nav li{
margin-bottom: 5px;
height: 25px;
line-height:25px;
}
While using absolute, every thing related/relating to that must be absolute in term of pixels.
I have updated fiddle, as your nav + logo .header + .nav:last-child were not totaling proper.
Fiddle link : http://jsfiddle.net/3TUk8/2/
in other case you will have to do that
nav ul
{
display: table;
background: #bbbbbb; /* that's what you see in webkit and same as bg color will hide it :) */
list-style: none;
}
I hope this solve your problem :)
I'm using 960gs to layout the page with a standard one column centred layout, header then nav then content then footer.
The #nav has vertical lists inside. If the client has javascript enabled then the lists (using JQuery) are set to pop down on hover (by changing display of the lower li's from none to block).
This means that the #nav has position: relative and a high z-index, with the #content set to position: absolute in order that the lists flow over the top of the content. Otherwise, the content moves down to accommodate the list.
It works great in Safari v5 and Chrome v11. However, FF v10 and Opera v11 (and IE but that's a given;) decide to offset the #content from the left beginning at the right edge of the nav, so around 800ish pixels to the right.
I've tried remedying this by setting the #container position to relative, but that does nothing. Put simply, the line position: absolute; is the one that changes things.
I'm at the limits of my CSS/positioning knowledge here, so any help would be much appreciated.
I've used Haml here because writing HTML is so cumbersome and verbose, but even if you don't know Haml you'll understand:
#container.container_16
#header.prefix_3.grid_10
%h1
My wonderful web site
#nav.prefix_3.grid_10
%ul.vert_nav.grid_2
%li.head
Home
%li.sub
About
%li.sub
Contact us
#content.prefix_3.grid_10
%p
Lorem ipsum...
#footer
%p
You've reached the end.
a bit of CSS:
#container {
height: auto !important;
min-height: 100%;
position: relative;
}
#content {
height: 100%;
padding-bottom: 1em;
padding-top: 0.2em;
position: absolute;
z-index: 1;
}
.container_16 .grid_10 {
width: 580px;
}
.container_16 .prefix_3 {
padding-left: 180px;
}
.container_12, .container_16 {
margin-left: auto;
margin-right: auto;
width: 960px;
}
#nav ul.vert_nav li {
margin-left: 0.3em;
margin-right: 0.3em;
text-align: center;
}
#nav li.sub {
background-color: #000000;
display: block;
position: relative;
z-index: 500;
}
and some js:
(function() {
jQuery(function($) {
$("li.sub").toggle();
$("#content").css("top", "12em");
return $("ul.vert_nav").mouseenter(function() {
return $(this).find("li.sub").show();
}).mouseleave(function() {
return $(this).find("li.sub").hide();
});
});
}).call(this);
In summary:
To allow menus to fly over the top of the content, I need position absolute on the content div.
It has to work with 960gs.
To go outside of these requirements it needs to be a really solid reason.
Rather than positioning the #content absolutely you should position the drop down items absolutely instead.
For example you could have:
HTML
<ul>
<li>
No drop down
</li>
<li>
A drop down
<ul>
<li>option 1</li>
<li>option 2</li>
</ul>
</li>
</ul>
CSS
ul li {
display: inline-block;
position: relative; /* for the absolutely positioned children */
}
ul li ul {
position: absolute;
top: 1em;
left: 0px;
}
Working example: http://jsfiddle.net/JeAH8/