div border positioning - css

I am having trouble positioning a border in a div id. The border doesn't follow the text within the div.
My HTML looks like this:
<div id="menu-left-top">
<ul class="menu-left-top">
<li>Kategorier</li>
</div>
<div id="menu-left">
<ul class="menu-left">
<li>Lamper</li>
<li>Møbler</li>
<li>Kunst</li>
<li>Design</li>
</div>
And this is my CSS:
#menu-left-top {
width:195px;
height:1em;
margin-top:5px;
border-top-style:solid;
border-width:thin;
border-color: #999;
}
ul.menu-left-top {
list-style-type: none;
height:1em;
}
ul.menu-left-top li{
}
ul.menu-left-top li a{
color:#000;
font-size:12px;
text-decoration:none;
font-family: "Gill Sans light";
}
ul.menu-left-top li a:hover{
color:#cf0036;
font-size:12px;
text-decoration:none;
font-family:"Gill Sans light";
font-weight:300;
}
#menu-left {
width:195px;
max-height:4em;
margin-top:5px;
border-top-style:solid;
border-bottom-style:solid;
border-width:thin;
border-color: #999;
}
ul.menu-left {
list-style-type: none;
}
ul.menu-left li{
}
ul.menu-left li a{
color:#000;
font-size:12px;
text-decoration:none;
font-family: "Gill Sans light";
}
ul.menu-left li a:hover{
color:#cf0036;
font-size:12px;
text-decoration:none;
font-family:"Gill Sans light";
font-weight:300;
}
You can see the result here. It's the navigation to the left that is my current problem. As you can see, the div floating right also has faults, but I don't know if it has anything to do with my initial problem?

No issue buddy, but for this also we dont need to separate the first menu item from others,
check these,
your html code will be like this :
<div id="menu-left">
<ul class="menu-left">
<li class="first">Kategorier</li>
<li>Lamper</li>
<li>Møbler</li>
<li>Kunst</li>
<li class="last">Design</li>
</ul>
</div>
if you want it like this
then you can use this css :
.first { border:#000 solid; }
.last{ border-bottom:#000 solid; }
and if you want it like this then you can use this :
.first { border-top:#000 solid; }
.last { border-bottom:#000 solid; }
you can use this for this
.first { border-top:#000 solid;
border-bottom:#000 solid; }
.last{ border-bottom:#000 solid; }

Remove the max-height property of the menu-left div.

there is a max-height? remove max-height:4em; or you can make it height:auto;

You have not closed your ul tags in this way , as you start any html tag also you have to end the html tag, this is for most of the m\html tags, so this is the main fault here, firstly you need to close your ul's ,
<div id="menu-left-top">
<ul class="menu-left-top">
<li>Kategorier</li>
</ul>
</div>
<div id="menu-left">
<ul class="menu-left">
<li>Lamper</li>
<li>Møbler</li>
<li>Kunst</li>
<li>Design</li>
</ul>
</div>
And the massive border around your list elements are coming due to
border-top-style:solid;
border-bottom-style:solid;
this is not a proper way to bordering, you can use as border:2px soild #00000; , and for more on this kindly update your layout here, just give me a blueprint of how you want to make it look, then i will help you in formatting these. Cheers. and use height:auto also

Use html format like this , as we do not need to differ the top menu, we can achieve this via this thing :
use this html code :
<div id="menu-left">
<ul class="menu-left">
<li class="first">Kategorier</li>
<li>Lamper</li>
<li>Møbler</li>
<li>Kunst</li>
<li>Design</li>
</ul>
</div>
and then the css changes are as :
.first { border-top:#000 solid; }
ul.menu-left li{
border-bottom:#000 solid;
}
this will make something like this, and border styles you can change according to you, if any queries then feel free to ask,

Related

How to remove gap between menu

I made this page in wordpress and foundation.I want to change the below menu :
into this:
My css to override foundation's app.css is as below:
.top-bar-section li
{
width:150px;
word-wrap:break-word;
border-bottom: solid 1px #BC9633;
float:left;
}
PART OF app.css
.top-bar-section li:not(.has-form) a:not(.button) {padding:0 15px;line-height:45px;background:#ffffff;}.top-bar-section li:not(.has-form) a:not(.button):hover {border-bottom: 1px solid #BC9633;padding-bottom: 1px;padding-bottom: 3px;border-bottom-width: 1px;border-bottom-style: solid;}.top-bar-section li.active:not(.has-form) a:not(.button) {padding:0 15px;line-height:45px;color:#000000;border-bottom: 1px solid #BC9633;padding-bottom: 1px;padding-bottom: 3px;border-bottom-width: 1px;border-bottom-style: solid;}.top-bar-section li.active:not(.has-form) a:not(.button):hover {background:#BC96633;color:#000000;}
HTML
<div class="menu-wrapper">
<div class="top-bar-container contain-to-grid show-for-medium-up">
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<!--<h1><?php bloginfo('name'); ?></h1>-->
<img src="img/fspb_logo.png" width="165" height="145" >
</li>
</ul>
<section class="top-bar-section" style="padding-top:55px;">
//below two lines display the menu
<?php foundationPress_top_bar_l(); ?>
<?php foundationPress_top_bar_r(); ?>
</section>
</nav>
</div>
</div>
***** I removed padding:0 15px;line-height:45px; from .top-bar-section li..and it turned out to be below:
How do I push the long menu up pls?
You could also check the padding/margin on the as well. That might be where the issue is. Or the line-height. Kind of hard to pinpoint the exact problem without the full source (html and css of the problem area). Hope that helps!
CSS
.top-bar-section li
{
width:150px;
word-wrap:break-word;
border-bottom: solid 1px #BC9633;
float:left;
padding-bottom: 0px;
line-height: 20px;
}
Below is my updated css
.top-bar-section li
{
width:103px;
/*word-wrap:break-word;*/
white-space:word-wrap;
border-bottom: solid 1px #BC9633;
float:left;
padding-top : 0; padding-bottom: 0; margin-bottom: 0;
margin-right:10px;
height:35px;
line-height:11px;
}
It turned out better than before and solved my problem. It's just that The ABOUT FSPB looks a bit weird. Only if the words can be used to stretch the line taking up by the line underneath it would be better. If anyone knows how to do that, pls feel free.Thanks all.
There is no Foundation way to accomplish this. You can either us a css positioning or a table valign approach depending on your goals. Here is a SO post that describes how to accomplish both.

converting this to css stylesheet

I get a little lost on css stylesheet syntax. My dilemma is that I have four <div> tags with ROUGHLY the same style, except the colors are different or one may float: left but another tag might not have that.
So I was thinking I could add id to all of these so that I can move these style statements into the stylesheet.
How would I address each individual id in the stylesheet? I'm thinking something like div#id or something. Lets assume basic div is already unavailable, but I want some abstract stylesheet tag that at least contains display:block and font-size:11px and then a more specific stylesheet tag to address each <div> tag by its id or class or name.
<div style="display:block; color:steelblue; float:left; font-size:11px;">Open Requests </div>
<div id="openNumber" style="display:block; color:steelblue; font-size:11px; clear:right;">13</div>
<div style="display:block; color:green; float:left; font-size:11px;">Completed Requests </div>
<div id="completeNumber" style="display:block; color:green; float:left; font-size:11px;">13</div>
I get a little turned around on the syntax for different selector types
Thanks for any insight
You could try the following:
css:
.floatLeft { float: left; }
.clearRight { clear: right; }
.open { color: steelblue; font-size: 11px; }
.complete { color: green; font-size: 11px; }
html:
<div id="openRequests" class="open floatLeft">Open Requests </div>
<div id="openNumber" class="open clearRight">13</div>
<div id="completeRequests" class="complete floatLeft">Completed Requests </div>
<div id="completeNumber" class="complete floatLeft">13</div>
A <div> is already a block-level element, so you don't need to specify display: block on it.
You can create a class .numbers(or whatever best describes your grouping of divs) to hold the shared styles, and add that class to the divs in question. Then, target individual divs with their id's for tweaking colors.
Something like this might help:
CSS
.numbers {
/* shared styles */
}
#one {
/* unique styles */
}
#two {
/* unique styles */
}
#three {
/* unique styles */
}
Organizing your styles, in a semantic and meaningful way, can be challenging, but the time you save maintaining your code is well worth it. For a much better summary of how to do this, you can read this article.
I would use multiple classes to group silimar styles together. Try to extract semantic meaning:
Something like this:
CSS:
.block11 { display:block; font-size:11px; }
.left { float:left; }
.clear-right { clear:right; }
.steelblue { color: steelblue; }
.green { color: green; }
HTML:
<div class="block11 steelblue left">Open Requests </div>
<div class="block11 steelblue clear-right" id="openNumber">13</div>
<div class="block11 green left">Completed Requests </div>
<div class="block11 green left" id="completeNumber">13</div>
since the id's have to be unique, you could add an ID to those and then use:
#openRegistration{display:block; color:steelblue; float:left; font-size:11px;}
#openNumber{display:block; color:steelblue; font-size:11px; clear:right;}
#completedRequests{display:block; color:green; float:left; font-size:11px;}
#completeNumber{display:block; color:green; float:left; font-size:11px;}
NOW, given the above, we can simplify it as:
#openRegistration,#openNumber,#completedRequests,#completeNumber{display:block;font-size:11px;}
#openRegistration{ color:steelblue; float:left; }
#openNumber{color:steelblue; clear:right;}
#completedRequests{ color:green; float:left;}
#completeNumber{ color:green; float:left; }
or IF you want, give them a class and use that:
.myClass{display:block;font-size:11px;}
#openRegistration{ color:steelblue; float:left; }
#openNumber{color:steelblue; clear:right;}
#completedRequests{ color:green; float:left;}
#completeNumber{ color:green; float:left; }
EDIT:
or IF you want, give them more than one class and use that:
.myClass{display:block;font-size:11px;}
.complete{ color:green;}
.open{ color:steelblue;}
#openRegistration{ float:left;}
#openNumber{clear:right;}
#completedRequests{ float:left;}
#completeNumber{ float:left; }
<div class="myClass complete" ...
You can define some CSS classes and assign them to your elements according to what you need. Just an example:
CSS:
.myDiv {
display: block;
font-size: 11px;
}
.left { float: left; }
.clear-both { clear: both; }
.steelblue { color: steelblue; }
.green { color: green; }
HTML:
<div class="myDiv left steelblue">Open Requests </div>
<div class="clear-both"></div>
<div id="openNumber" class="myDiv steelblue">13</div>
<div class="myDiv green left">Completed Requests </div>
<div id="completeNumber" class="myDiv green left">13</div>
In this way you can separate your classes and use them only when you really need it.
You can use a class for the similarities, and an id for the differences.
<div class="common" id="some-id"><!-- ... --></div>
CSS:
.common {
display: block;
float: left;
font-size: 11px;
}
#completeNumber {
color: green
}

Why does the background of my container/wrapper not extend behind all content

Im working on a portfolio for uni and the background of my container / wrapper does not extend vertically enough in order for all its content to have a back ground color. I'll post code below, any help would be appreciated.
HTML
<body>
<section id="wrapper">
<header>
<hgroup class="title">
<h1>Matt Murphy</h1>
<p>Personal Portfolio | University of Leeds | BA New Media</p>
</hgroup>
</header>
<nav>
Home
About Matt
</nav>
<section id="modules">
<h2>Modules Studies To Date</h2>
<section id="year_1">
<h3>Year 1</h3>
<p>History of Communications</p>
<p>Academic Skills and Contemporary Issues</p>
<p>Interface Design</p>
<p>Design For New Media</p>
<p>Basic Camera and Editing</p>
<p>Animation For New Media</p>
</section>
<section id="year_2">
<h3>Year 2</h3>
<p>Dynamic Web Programming</p>
<p>Communications Research Methods</p>
<p>Working in New Media/p>
<p>Media Policy</p>
<p>New Media Narrative and Gaming</p>
<p>Visual Communications</p>
</section>
</section>
</section>
</body>
CSS
body{
color:#000;
background-image: url(images/canvas.png);
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
a:link {
text-decoration:none;
color:#000;
}
a:visited {
text-decoration:none;
color:#000;
}
a:hover {
text-decoration:none;
color:#000;
}
a:active {
text-decoration:none;
color:#000;
}
#wrapper {
background-color:#FFF;
padding:3%;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
display:block;
margin:auto;
width:60%;
margin-top:2%;
}
header {
text-align:right;
}
#modules {
width:100%;
display:block;
margin:auto;
}
#year_1 {
float:left;
}
#year_2 {
float:left;
}
To fix your problem you just need to add overflow: auto to #wrapper.
#wrapper {
background-color:#FFF;
padding:3%;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
display:block;
margin:auto;
width:60%;
margin-top:2%;
overflow: auto; /* add this line */
}
However, another issue is that you are using HTML5 elements and the HTML5 shiv but you have not used the HTML5 doctype:
<!DOCTYPE html>
I assume you are having problems in IE? You are missing a doctype declaration. If you add a transitional doctype as per the example on W3Schools below it should work.
HTML doctype declaration
Basically the css-property 'float' on the section#year is the bad guy here.
If I replace your sections with div's and add an extra div to clear block rendering it works:
http://jsfiddle.net/hoedinie/537sL/1/

CSS List Styling Not Lining Up

Trying to get these list headings to line up correctly, but I can't figure out the justification to get it to line up. Trying to style it like the second one but those bold tags are pushing it down a line.
<div class="block">
<ul class="toc partThree">
<li><b>39:</b>Maintaining This Diet</li>
<br/>
<li><b class="parts">Part 3A:</b><a class="partslink" href="#"> About Fruit Consumption</a></li>
<li><b>40:</b>Ideal Fruit-combinations</li>
<li><b>41:</b>Fruits To Go</li>
<li><b>42:</b>Salads & Shakes</li>
<li><b>43:</b>Fruits In General</li>
<li><b>44:</b>About Consuming Nuts</li>
<br/>
<li><b class="parts">Part 3B:</b><a class="partslink" href="#"> About Consuming Animal Food</a></li>
<li><b>45:</b>About Fresh Raw Fish</li>
<li><b>46:</b>About Fresh Raw Egg Yolk</li>
<br/>
<li><b class="parts">Part 3C:</b><a class="partslink" href="#"> The Most Important Section of This book</a></li>
<li><b>47:</b>Remember That...</li>
<li><b>48:</b>The Rules</li>
<li><b>49:</b>The Obstacles</li>
<li><b>50:</b>Cravings</li>
<li><b>51:</b>Traps</li>
<li><b>52:</b>How To Pick Munch-foods</li>
<li><b>53:</b>Protein Contents</li>
<li><b>54:</b>Single Munch-food Items</li>
<li><b>55:</b>Munch-food Meals</li>
</ul>
</div>
Here is the CSS:
.toc{
list-style:none;
font-size: 15px;
}
.toc li{
margin:0 0 0 10px;
width: 220px;
overflow:hidden;
font-size:13px;
font-family:Arial;
}
.toc b{
float:left;
padding: 0 4px 0 0;
font-weight:bold;
}
.toc a{
float:left;
width:191px;
padding:0 0 0 0px;
color: black;
text-decoration:none;
}
.toc a:hover{
color: rgba(0,0,0,.8);
text-decoration: underline;
}
b.parts{
}
a.partslink{
}
http://jsfiddle.net/QbUvD/
Made some adjustments, particularly removing floats. This is assuming you don't use the suggestion above of the counter-reset (although with that you'd have to restructure a lot of your HTML it seems).
the trick I used here is to add a padding-left to the li's that are title (add a class .title) then using a negative text-indent to wrap back the first line, but allow the second one to keep the padding. The only downside here is the need for a manual width on the padding/indent values, but it achieves the look you want.

Overlapping Lists, CSS isn't pushing it down

I've added padding and margin to the li's themselves, but it spaces them out too far. I'm trying to figure why the longer chapters won't just push the bottom li down a line and keep on going.
Here is the test page.
This is my HTML:
<div id="sidebar">
<h2> Contents </h2>
<div id="accordion">
<h3>Part 1: Food the Skin</h3>
<div>
<ul id="partOne" class="toc">
<li><h3>01:</h3>The Use of Fire</li>
<li><h3>02:</h3>Downsides to Using Heat</li>
<li><h3>03:</h3>Altered Protein</li>
<li><h3>04:</h3>Protein Digestion</li>
<li><h3>05:</h3>Protein in the Skin</li>
<li><h3>06:</h3>Decomposition of Redundant Protein</li>
<li><h3>07:</h3>Protein & Water</li>
<li><h3>08:</h3>Swollen Skin,Cellulite & Treatments</li>
<li><h3>09:</h3>Dry Skin</li>
<li><h3>10:</h3>How to Rid </li>
<br/>
<li><h3>11:</h3>Cellulite</li>
<li><h3>12:</h3>Visibility of Fat Cells </li>
<li><h3>13:</h3>Cellulite & Skin Tone</li>
<li><h3>14:</h3>Cellulite & Treatments</li>
<br/>
<li><h3>15:</h3>Acne: In Short</li>
<li><h3>16:</h3>Acne & Hygiene</li>
<li><h3>17:</h3>Acne & Hormones</li>
<li><h3>18:</h3>Acne & Peeling </li>
<li><h3>19:</h3>How to Eliminate Acne, Cellulite & Treatments</li>
<li><h3>20:</h3>What Type of Acne</li>
<li><h3>21:</h3>Susceptibility to Acne</li>
<li><h3>22:</h3>Menstruation & Acne</li>
<li><h3>23:</h3>Acne & Diet-results, Cellulite & Treatments</li>
</ul>
</div>
<h3>Part 2: Nutrients & Toxins</h3>
<div>Second content</div>
<h3>Part 3: The Diet</h3>
<div>Second content</div>
<h3>Part 4: Losing Weight Naturally & Lastingly</h3>
<div>Second content</div>
</div>
</div>
Here is my CSS:
#accordion{
margin: 10px;
}
#accordion h3{
font-size:16px;
}
#accordion h3 a{
}
#accordion h3 a:hover{
}
.toc{
list-style:none;
font-size: 14px;
}
.toc li{
width: 220px;
height:18px;
}
#accordion div > ul{
padding: 10px 0 0 0;
}
#partOne h3{
float:left;
width: 25px;
padding: 0 3px 0 0;
font-weight:normal;
}
#partOne a{
color: blue;
text-decoration:none;
}
#partOne a:hover{
text-decoration: underline;
}
Can't get this problem solved after a couple of hours!
Remove the height property from the .toc li style declaration:
.toc li {
width: 220px;
}
DEMO
If you'd like to set the line height of the lis, use line-height CSS property. Also, consider replacing & with &, reference HTML Entities.
I'm not real sure what you're trying to do, but why not use an ordered list instead so you don't need to manually type the parts?
It's doing that because you are fixing the height of the LIs, if you remove the height you will also have to "contain" or "clear" the floated H3s. One way to do that is to set the LIs overflow property.
.toc li {
width: 220px;
overflow:hidden;
}
http://www.quirksmode.org/css/clearing.html
(Also I'm pretty sure putting those BRs in the UL where you have is not valid HTML)

Resources