I got a problem with the outlining of some div elements.
I got the following structure.
<div id="skillcontent">
<div id="skillname" class="inline">
<div class="skilllist">
<div><h3>[SKILL]</h3></div>
<div><h3>[SKILL]</h3></div>
</div>
</div>
<div id="skillstars" class="inline">
<div class="skilllist">
<div>
<img src="img/star_active.png" alt="" />
<img src="img/star_active.png" alt="" />
<img src="img/star_inactive.png" alt="" />
<img src="img/star_inactive.png" alt="" />
<img src="img/star_inactive.png" alt="" />
</div>
<div>
<img src="img/star_active.png" alt="" />
<img src="img/star_active.png" alt="" />
<img src="img/star_active.png" alt="" />
<img src="img/star_inactive.png" alt="" />
<img src="img/star_inactive.png" alt="" />
</div>
</div>
</div>
<div id="skillinfo" class="inline">
<div class="skilllist">
<div><h4>[YEARS],[LEVEL]</h4></div>
<div><h4>[YEARS],[LEVEL]</h4></div>
</div>
</div>
</div>
Css:
.skilllist div {
padding: 0px;
margin: 0px;
display: block;
height: 25px; /*same height as star images*/
}
div.inline {
display: inline-block;
}
h3 {
font-size: 18px;
color: #5b5b5b;
margin: 0px;
}
h4 {
font-size: 18px;
color: #808080;
margin: 0px;
}
img {
vertical-align: bottom;
}
The divs that contain the text (h3 and h4) elements are a bit smaller as the divs that contain images. There is no margin or padding on any element. The height of all of the divs is the same but there still is some whitespace on top of the divs with the class skilllist that contain text. There is no whitespace above the div that contains images.
Why is this and how can i fix it?
Example: Click
try adding vertical-align:top; to your css on all items misaligned. worked when i did this using firebug on your test page.
Several things:
You seem to be misusing HTML elements: h3, h4, etc. are for headlines.
On the other hand, you use too many divs. Consider the many other HTML elements that exists. For example, the elements you call "skillist" scream to be lists (ol,ul).
If you are worried about small pixel gaps like that, HTML/CSS may be the wrong tool for you. The whole concept of HTML/CSS is to be flexible and allow for different renderings on different systems and not to be a pixel perfect design tool.
Your problem may be because by default images are inline elements that sit on the font baseline and leave space for descenders. Try setting vertical-align: bottom on the images.
Without seeing your CSS, it's hard to say.
You have to remember that every element has default styling provided by the standard/browser. In order to trump this, you have to explicitly define your own values.
For example, most browsers define a page background's default color to be: #FFFFFF
To change it, you have to provide your own value.
Hope this helps.
It could be down to the margins that browsers automatically add to h tags (as well as p and some other tags).
It may help to use a css reset style sheet to remove a lot of the default margins and padding which various browsers render differently. There's one at http://developer.yahoo.com/yui/3/cssreset/
I agree with tobiasmay - it'd help if we had a demo page or something like that.
can you post some css or set up a jsfiddle.net please? else it's hard to help you fix your divities..
//EDIT
here you go, i fixed your markup completly:
<div id="skills">
<div class="skillA">
<h3 class="skill">Skill A</h3>
<ul class="skillRow">
<li><img src="http://www.ethanol-online.eu/star_active.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_active.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_inactive.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_inactive.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_inactive.png" alt="" /></li>
</ul>
<p class="foo">Years, Level</p>
</div>
<div class="skillB">
<h3 class="skill">Skill B</h3>
<ul class="skillRow">
<li><img src="http://www.ethanol-online.eu/star_active.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_active.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_active.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_active.png" alt="" /></li>
<li><img src="http://www.ethanol-online.eu/star_inactive.png" alt="" /></li>
</ul>
<p class="foo">Years, Level</p>
</div>
</div>
and the CSS with a working ul li
#skills{
background-color:lightgreen;
overflow:auto;
}
.skillA, .skillB{
overflow:auto;
margin-bottom:10px;
}
ul.skillRow{
display: inline;
}
ul.skillRow li{
list-style-type: none;
float:left;
}
p.foo{
float:left;
font-size:18px;
padding:6px;
}
h3.skill{
float:left;
display:inline;
padding:6px;
}
here's the fiddle link: http://jsfiddle.net/tobiasmay/gKrkS/
Add vertical-align: top or vertical-align: bottom (whichever you prefer) to the div.inline rule. That makes it work in all browsers.
The reason the div with the images is positioned a little higher than the others is due to the way inline-blocks are aligned in their containing line box:
(...) [B]oxes are laid out horizontally, one after the other, beginning at the top of a containing block. Horizontal margins, borders, and padding are respected between these boxes. (...) The rectangular area that contains the boxes that form a line is called a line box.
(...)
A line box is always tall enough for all of the boxes it contains. However, it may be taller than the tallest box it contains (if, for example, boxes are aligned so that baselines line up). When the height of a box B is less than the height of the line box containing it, the vertical alignment of B within the line box is determined by the 'vertical-align' property.
Note the bold part. The default value of vertical-align is baseline. The images in your example are moved up in the line box to align them to the baseline of the surrounding text. In doing so they increase the height of the line box, leaving some extra whitespace on top of the text divs.
If you still don't quite understand what's happening, try increasing the font-size of the h4 in your example to, say, 32px, and remove the fixed height from .skilllist div.
Related
i have 3 thumbs i want to center in a row. The code is
<div class="large-12 columns">
<ul class="small-block-grid-3">
<li><img class="shadow" src="img/thumbs/carWashHome.jpg"></li>
<li><img class="shadow" src="img/thumbs/homeCleanHome.jpg"></li>
<li><img class="shadow" src="img/thumbs/carpetCleanHome.jpg"></li>
</ul>
</div>
But somehow the thumbs are starting from left and not in center.
can you suggest be how to fix that.
here is the picture
Here is the link LINK
You can see that the thumbs are floated to left.
how to center them.
thanks.
Replace a line with following
<div class="large-12 columns" style="text-align: center;">
Key is to add style="text-align: center;" and problem will be fixed
Thanks for posting the URL.
Just add text-align:center; in your .small-block-grid-3 > li{}
Please let me know if you have concerns.
CSS
.small-block-grid-3 > li{
text-align:center;
}
Add this css to your image tags:
display: block;
margin-left: auto;
margin-right: auto;
It will align image to center present in li tag.
Might be nice to know to, that foundation also has a CSS class called "text-center" that can be applied to elements as needed :-)
<div class="text-center">
content goes here...
</div>
I am trying to create a website that requires fluid re-sizing. How ever the positioning does not seem to work for the "top" or "bottom" when I use %. It works fine when I use px or em.
i am trying to position the slider of a jquery showcase called flexslider 2. it is a div element that is linked to two images. an example of the original html can be found here at the bottom. http://flexslider.woothemes.com/
<div style="padding:5px;">
<div class="flexslider">
<ul class="slides">
<li><img src="images/ussc1.jpg" alt="01" /></li>
<li><img src="images/ussc2.jpg" alt="02" /></li>
</ul>
</div>
</div>
and here is the css.
.flexslider {
max-width:940px;
width: 40%;
margin: 0 auto;
top: 20%;
position:absolute;
}
What am I doing wrong? Please help! I do apologise in advance, i am very new to web design
Check your spelling of "postion", should be:
.flexslider{
position:absolute;
}
If the position isn't specified properly the "top" and "bottom" styles won't work with percentages!
I'm attempting to create a complex div structure using CSS.
I want it to be made up of four columns. On the left is just a list of images. On the right is the complex div structure that I can't figure out a way to create. There should be two large vertical boxes containing various details. In-between these vertical boxes are any number of horizontal boxes.
My problem is that I cannot work out how to create this div structure in a way that 'scales', i.e. there could be any number of horizontal boxes between the two vertical boxes.
This is the div structure I was attempting to use:
<div class="result">
<div class="detail_1">
<p>Detail 1</p>
</div>
<div class="details">
<p>Details</p>
</div>
<div class="details">
<p>Details</p>
</div>
<div class="detail_2">
<p>Detail 2</p>
</div>
</div>
Any help would be greatly appreciated!
EDIT: I have fixed this problem by just using tables. Thanks for the replies.
Update 2
Your question is: How to make the price & flight_number div the same height as the parent div (container)..
1) Use the technique described here: http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks
2) update your CSS so that the flight number and the price are vertical aligned in the middle of their div.
I think that mine HTML structure is better then yours because it's more clear and easier to work with.
So based on my HTML structure: The parent container (flight_info) is stretchend as long as the content inside (the table with the rows will be the longest). the div's flight_number and price are also the total height of the parent container thanks of the technique described in step 1 above. The extra CSS (step 2) will align the price and flight number nicely in the middle.
OLD
<ul id="flights">
<li>
<ul class="images">
<li><img src="img1" alt="your image" /></li>
<li><img src="img2" alt="your image 2" /></li>
</ul>
<div class="flight_info" id="flight_EK49">
<div class="flight_number">
EK49
</div>
<table>
<thead>
<th>date</th>
<th>from</th>
<th>to</th>
</thead>
<tbody>
<tr>
<td>1/1/2013</td>
<td>departure airfield</td>
<td>destination airfield</td>
</tr>
...
</tbody>
</table>
<div class="price">
€999,99
</div>
</div>
</li>
// duplicate the above for a new flight..
</ul>
And for the CSS style (you must do the rest on your own because this is just an example. I didn't test any of the code):
<style>
#flights .images {
float: left;
width: 250px;
}
.flight_info {
float: left;
width: 700px;
}
.flight_info .flight_number,
.flight_info .price {
float: left;
width: 150px;
}
.flight_info .price {
float: right;
}
.flight_info table {
float: left;
width: 400px;
}
</style>
I think you will get the idea.
EDIT 1
Changed all the position absolutes to floats because it easier with the li's automatic heights.
I also added the leg images of the flight as well, but as I mentioned, you have to do the rest yourself ;)
I am trying the Blueprint CSS framework, and am having a hard time figuring out how to do the overall layout.
It seems Blueprint (as far as I have understood it so far) makes you use a set page width at 950px. I guess you could change that with some modification, but in any case there has to be some width, so that's fine. The problem is, even if I want the main content of the page to be 950px wide, I want 100% wide headers and footers.
So I have placed a header and a footer outside the main "container" div that's 950px wide. I set the header div to 100%. And then I have a "headerContent" div inside it (containing menu, logo, etc), which has a 950px width (span-24 in Blueprint terms). But I want the headerContent div to be centered within the header div.
I have always used the "margin: 0 auto" trick to do this, but for some reason it doesn't work at all now.
Here's the html:
<div id="header" class="blueheader">
<div id="headerContent" class="span-24">
<div id="logo" class="span-6">
<a href="/">
<img src="/images/expertinfo.png" width="230" height="62" />
</a>
</div>
<div id="menucontainer" class="span-14"><ul id="menu"><li>
<a href='/Services/Index'>TJÄNSTER</a></li>
<li>
<a href='/About/References'>KUNDER</a></li>
<li>
<a href='/About'>OM OSS</a></li>
<li>
<a href='/About/Contact'>KONTAKT</a></li>
</ul></div>
<div id="logindisplay" class="span-2">
Logga in
</div>
</div>
</div>
And here's the css for header and headercontent:
#headerContent
{
overflow: auto;
zoom: 1;
margin: 0 auto;
}
#header
{
width: 100%;
position: relative;
margin-bottom: 0px;
color: #000;
margin-bottom: 0px;
overflow: auto;
zoom: 1;
}
The overflow and zoom part is just another trick I read about to avoid having to use empty divs to clear containing divs, and I tried without them with no luck, so they have nothing to do with the problem.
Any ideas what I'm doing wrong?
You need to set a width the the #headerContent because without it defaults to width:100% if you place a 950px width to the div, you should be fine.
Found the answer: you shouldn't use span-24 on the headerContent apparently in the Blueprint framework, but rather the container class. Here's what worked:
<div id="header" class="blueheader">
<div id="headerContent" class="container">
<div id="logo" class="span-6">
<a href="#Url.Action("Index", "Home")">
<img src="/images/expertinfo.png" width="230" height="62" />
</a>
</div>
<div id="menucontainer" class="span-14">#Html.Raw(Html.Menu())</div>
<div id="logindisplay" class="span-2">
#Html.Partial("_LogOnPartial")
</div>
</div>
</div>
I cannot say I understand exactly why it didn't work before, and that worries me, because I am trying this framework to simplify layout, but this made it harder to understand. As far as I could see it should have worked with the first code too...
I've a inside container div. Now this gallery div (of set width = 800px) houses lots of thumbnails of sizes 100x100. The thumbnails are taken out from a database, and the number of thumbnails can vary based on the query used. Also, each of the thumbnails are set to "float:left" within the gallery div.
Now the question is, assuming 8 thumbnails get placed in each row, and assuming that 3 such rows got created by the query, can I give a border-bottom design to these rows?
Basically the question is, can i specify the border properties for the rows that are created by floating elements within a set width.
Thanks!
My contribution:
<ul>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
<li>
<img src="" alt=""/>
</li>
</ul>
ul { width:500px; }
img {
width:50px;
height:50px;
}
li {
float:left;
border-bottom: 1px solid grey;
padding: 5px 5px 0;
}
Live: http://jsfiddle.net/Bduxm/5/
As far as I read your question.. then no, it's not possible as it stands.. your pseudo three "rows" are not actually wrapped in individual containers so there is nothing to put a border on
the answers you have so far assume you count the min/max number of images selected and wrap up to 8 in a containing element.. this containing element could then be given the border.. however I read from your question the number may vary depending on a query, could you add something to the query to wrap up to eight elements in each row?
added: you could probably use a repeating background image on the container with horizontal lines about 100px apart, then margin the images to leave space to show the line/borders
Why not make the parent div's background the color of the border you want, then make the thumbnail's background white with no margin to the left/right, but a margin at the bottom/top. Make sure there is enough padding around each thumbnail so there is enough white. Then you get a nice grid with horizontally appearing rows.
You could fake it, though you'd need a little more markup.
With this HTML:
<div id="container">
<div class="imageWrapper">
<span class="fakeRowBorder">clever, huh? ;-)</span>
<img src="somesrc" />
</div>
<div class="imageWrapper">
<span class="fakeRowBorder">clever, huh? ;-)</span>
<img src="somesrc" />
</div>
... [etc.]
</div>
And this CSS:
#container{position:relative;width:400px;}
img{width:50px;height:50px;outline:1px dotted green}
.imageWrapper{float:left;position:static;margin-bottom:30px;}
.fakeRowBorder{position:absolute;left:40px;right:40px;margin-top:55px;border-bottom:1px solid blue;text-align:center;font-size:9px}
As long as the .imageWrappers are positioned static (default) then the absolutely positioned .fakeRowBorders will use #container as their reference grid for any positioning properties (top, right, bottom, or left). If you don't specify top or bottom on those fake borders, then they are calculated per how they would be were they positioned normally (rather than taking 0 as a default, as one might think) -- and that's the trick: specify "left" and "right" properties for each one, but leave "top" and "bottom" un-specified.
Adjust top and bottom padding or margin on the image and the fake borders to play with the spacing.
Check out how it works here:
http://jsfiddle.net/5S6j9/3/
Revision
clairesuzy pointed out that the solution didn't work in IE, so I've revised it, including adding in display:block to the fake border, as she suggested.
Also, (partly just to show off) I added some text centered in the row border, and brought it in from the left and right edges of the #container to demostrate how it displays apparently independently of the individual images.
Use tables...
<table id="container" style="width:800px">
<tr style="border-bottom:1px solid black">
<td class="thumbnail">thumbnail</td>
...
</tr>
...
</table>
CSS:
.thumbnail { width: 100px; }
hmm.. i've been thinking about MY own question.. and here's my quick thought on it (i've not yet coded to confirm) -
i guess, if the container element is set with a background-image with say a height of 200px (depending on the thumbnail height calc, it could vary) and a thin 1px line at the bottom of this image (for faking the border), we could do a repeat in both x and y, so that this image will do the border (border for the bottom of each row) setting.
how's that?!
psuedo code for what i think might work -
#container
{
width:1000px; height:auto; margin:0; padding:0;
background-image:url('image-of-height-and-width-100px-each-and-a-thin-line-at-bottom.png');
repeat:x; repeat:y;
}
.thumbnails{
float:left; width:80px; height:80px;
}
how about that?!
guys, seriously thanks for the suggestions.