Dotted Line Html Span - css

I have a menu coded in html here, but i need a dotted line to span between the Names and Prices, How would i go about doing that here? I'm kinda lost haha.
You can see it here.
http://mystycs.com/menu/menuiframe.htm
I know i can use css to do it, but how would i get to it span between those two.
Thanks =)

<style type="text/css">
.menugroup{
width:100%;
}
.itemlist{
list-style-type: none;
}
.separator{
margin: 5px;
width:50%;
border-bottom: 1px dotted #000
}
</style>
<div class="menugroup">
<ul class="itemlist">
<li>item name<span class="separator"></span>price</li>
</ul>
</div>

Wow, where to start? What you have is a number of lists with headers above each, some with notes above and/or below, so that's the markup you should be using:
<h2>Egg Platters</h2>
<div class="note">Served With Home Fries & Toast</div>
<ul>
<li><span class="item">Two Eggs Any Style</span><span class="separator"> </span><span class="price">2.75</span></li>
(etc.)
</ul>
<div class="note">Add On Any Two Slices ...</div>
<div class="note large">Add Coffee for $0.50 with ...</div>
Your class="price" is fine, but class="red" and <strong class="bold"> are poor choices -- name the class based on why it's red (like my "note"). Using headings eliminates the need for "bold" to make the <strong> text bigger.
Now, I put in the <span class="separator"> so you could give widths, or use floats, and allow the separator blank space to expand to fill between the item and the price, and you could style it with something like
.separator {
border-bottom: 1px dotted #333;
}
EDIT:
I agree with ClarkeyBoy's comment too; limiting the overall width would help readability, and TripWired's link shows some good method (and uses essentially what I was suggesting)

Have you considered something like this?
http://5thirtyone.com/archives/776

Normally I wouldn't suggest tables... but this case would fit a table quite nicely.
I'd forgo dotted lines as they would be very bad for usability (if you've got a page of dotted lines, it's very cluttered and hard to follow each one - you'd probably use your finger on the screen like you would a menu - not good).
Instead why not a table with alternate row colours, which might look quite nice. Then have a rollover state that would highlight the whole row, to make it completely obvious for the user what each item costs.
There's a great example tutorial with code here (see example 3): http://bit.ly/9jTnAx
The code is at the bottom of the page, and is pretty much just copy paste from your end.
Good luck!

I would use a background x repeated .gif on the whole line and hide it with a white bg color on the float left item name and float right item price.
.line{
clear:both;
margin-bottom:15px;
background:transparent url(img/common/dot.gif) repeat-x scroll 0 0;
height:22px;
}
.label{
background-color:#FFF;
padding-right:2px;
float:left;
}
.price{
float:right;
background-color:#FFF;
padding-left:2px;
}

<style>
table th, td{
border-bottom: 1px dotted #CCCCCC;
}
HTML code block:
<h3>Current House Trends</h3>
<table class="table" border="0">
<tbody>
<tr>
<th>Price</th>
<td>$500,000</td>
</tr>
<tr>
<th>Market</th>
<td>78</td>
If you want to put '-' in between you can add an extra column in the middle which contains '-' or similar of your choice.

Related

Div positioning - putting one after another

Imagine a math problem on the web. I would like to display the math problem and then have the user be able to type their answer to the right of it. I am trying to set up the structure. I have custom buttons that I will use to change the inner text of the answer.
The math problem is given by "problemtext" and the answer is given by "problemanswer". When the user taps on the number pad, I will place that number in the "problemanswer" segment.
The problem with this set up is that the answer is showing up below the problem.
But I want the answer to be directly to the right of the problem, not below it. Further, I'd like the answer to have a box (or border) around it. How can I do this? What should my html/css look like?
<div id="problem" class="text" style="display:none">
<div id="problemoverall" align="center">
<div id="problemtext" style="font: bold 65px Arial;">
</div>
<div id="problemanswer" style="font: bold 65px Arial;">
</div>
</div>
</div>
Here's some relevant CSS I have
.text {
text-align:center;
font-size:16px;
line-height: 165%;
color:#f1f1f1;
}
.text p {
margin: 8px 0;
}
Use display: inline;. Add this css rule:
#problemtext, #problemanswer{
display: inline;
}
Have a look:
http://jsfiddle.net/cherniv/dPSav/1/

3-col navigation menu with images

I am working on the css for a website and am trying to determine the best approach for the navigation menu. The layout of the menu is as follows:
between col 1 and 2, and also between col 2 and 3 are double vertical lines, which because of their style will probably need to be an image.
SO, my question is this:
Semantically, all of these links are part of one unordered navigation list. But, I can't find any way to create such a list using css only that will work in IE. The images between list items only muddles it up more. Is there a clean way to do this?
My second approach was to create 3 columns, and place a list in col 1 and col 3. But this still seems messy with the image dividers. I thought about using li:after to place the images, but IE7 doesn't recognize the "content" property.
Right now, it seems like the cleanest way to build this is without lists. But then I feel like I'm losing proper semantics. Is there a better approach that I'm not thinking of? The layout is very tabular, so I could certainly make it a table . . . : )
Thanks!
I solved as follows for links where you substitute the names you need and the class image with the image and your measurements.
<style type="text/css">
ul{
width:400px;
height:200px;
}
ul li{
border-top:1px solid gray;
border-bottom:1px solid gray;
display:block;
height:99x;
width:100px;
}
.left{
float:left;
}
.right{
float:right;
}
.second{
margin-top:100px;
margin-left:-100px;
}
.image{
background:red;
border-left:3px double gray;
border-right:3px double gray;
display:block;
float:left;
height:200px;
width:194px;}
</style>
<body>
<ul>
<li class="left">Home</li>
<li class="left second">Home</li>
<li class="image">Home</li>
<li class="right second">Home</li>
<li class="right">Home</li>
</ul>
<body>
I hope I can help. A greeting.
I think that you can make one UL with four LIs and give absolute position to first and last li (maybe "events" and "about us"). This can be achieved by pseudo selectors :first-child and :last-child.

Evenly space words except when in multi-word phrases (like 'human rights')

How can I evenly space (ie. fully justify) words to fill a line except when in multi-word phrases (like 'human rights') to create an effect like the below?
you should use an html list for a nav menu:
tutorial here but many other if you google them:
http://jamesowers.co.uk/css-tutorials/50/horizontal-css-list-menu/
reasons behind it:
your menu will look good if css does not load / not supported
helps accessibility
semantically, you are displaying a list of items - so what's better than a list to display them?
EDIT
the easiest, html/css only, solution is to use a table, however my eyes burn at the sight of a table used for layout. (Depending on the browser support you want to offer, you may get away with ul li or nested div tags and css display:table-cell/table-row etc)
fiddle here: http://jsfiddle.net/nTM3S/
<table cellpadding="3" class="myTable" style="text-align:center">
<tr>
<td>Politics</td>
<td>Environment</td>
<td>Economics</td>
<td>Culture</td>
<td>Human Rights</td>
<td>Politics</td>
<td>Environment</td>
<td>Economics</td>
<td>Culture</td>
<td>Human Rights</td>
</tr>
</table>
and css:
td {
width: 1%;
padding: 20px;
white-space: nowrap;
background-color: #ccc;
color: #900;
}
Put you items into an <ul> and add margins to each <li>
See demo: http://jsfiddle.net/L8qnh/3/
Html
<ul>
<li>Politics</li>
<li>Enviroment</li>
<li>Economics</li>
<li>Human Rights</li>
<li>Country</li>
</ul>
Css
ul{
list-type:none;
}
li{
float: left;
margin-right: 40px;
}
Apply text-align: justify; to the line of text you want evenly spaced, and write multi-word phrases (like 'human rights') thus (adjusting the padding appropriately):
<span style="padding-right:3px;">Human</span>rights
Depending on which browsers you want this to work in, the answer to your question may be as simple as putting a in the phrases you want to keep together.
Politics Enviroment Economics Human Rights Country
And then, justify the whole thing. See jsFiddle.
Unfortunately, this doesn't work on all browsers; it's OK in IE8 and Opera, but Firefox and Chrome do stretch the nbsp just like the other spaces.
I would use a div for each element, and set their display properties to inline... and example would be:
<html>
<head>
<style type="text/css">
.food{
padding:5px;
display:inline;
}
</style>
</head>
<body>
<div class="food">Hamburger</div>
<div class="food">Pizza</div>
<div class="food">Hot Dog </div>
<div class="food">Chicken</div>
</body>
</html>

Specifying exact percentage widths in relation to parent DIV in CSS

I am attempting to create a visual element using DIV elements and CSS which should display data in the format demonstrated below.
[-----50%-----|--25%--|--25%--]
When using the code and CSS I've specified below, my final element always spills onto the next line and the CSS percentage values I'm specifying don't seem to create the layout properly.
Could anybody suggest a better way to do this?
My HTML
<div class="visual-indicator-title">
All Items</div>
<div class="visual-indicator-holder">
<div class="vi-internal-element" style="width: 25%; background-color: #5E9BD1;">
25%</div>
<div class="vi-internal-element" style="width: 25%; background-color: #AB884D;">
25%</div>
<div class="vi-internal-element" style="width: 50%;">
50%</div>
</div>
<div class="visual-legend">
<ul class="inline-block">
<li>
<div class="legend-blue">
</div>
Sales</li>
<li><span class="legend-tan"></span>Processed</li>
<li><span class="legend-grey"></span>Pending Processing</li>
</ul>
My CSS
.visual-indicator-title{
font-size:12px;
font-weight:bold;
color:#777777;
}
.visual-indicator-holder
{
width:100%;
background-color:#666666;
height:28px;
border-radius: 8px;
}
.visual-indicator-holder .vi-internal-element
{
font-size:11px;
text-align:center;
color:#ffffff;
background-color:#777777;
border-radius: 6px;
display:inline-block;
}
The reason this happens is that with inline or inline-block, white space in the element will affect the rendering (adds space). Here is your demo working with white space removed, no changes to the CSS: http://jsfiddle.net/fZXnU/
Removing white space is not trivial though, so you'd be better off floating the elements (which triggers display:block). Working demo with plenty of white space: http://jsfiddle.net/fZXnU/1/
You can use float: left, position: relative, and then define width in percentage as you are.
I modified your code to use float here: http://jsfiddle.net/Z3kdP/.
If you remove the white-space between the divs then it works as intended.
http://jsfiddle.net/TeJuU/
EDIT: See this question: How to remove the space between inline-block elements?
You can make font-size: 0 on the parent element if you don't want to edit your html.
http://jsfiddle.net/TeJuU/1/
All of those elements have margin and padding with them as well as the percentages creating rounding errors during calculation. So you need to make sure you set, or take into consideration, what margin is doing to this. For rounding errors, it's typical to let the percentages add up to something less than 100% but then add margin: auto to center the whole thing.

How to underline every line of text, to the end of a block

So, here's my question, I'm doing a newsletter for a customer, which will look like a postalcard.
I want my layout to look like writing on lines
Can anyone help me achieve what I'm trying to do?
Putting my text in TD tags doesn't work since I don't know the length of each sentences.
Let me know if you need more info!
Thanks :)
I just ran into this issue where a client "needed" to have a notes section on a print-out with user-entered note text underlined as if on spiral-bound paper. (I've learned to stop asking why.) Why didn't I use a background image? It won't print out, so not an option.
Here's the structure (IDs for clarity):
<p id = "p">
<span id = "span1">
<span id = "span2">
sadfa sdfhkas dfjkahsd fhjklasdg f askjldfh jklas djklfh aljks hfjkl hasjdklfg hjlashdjlfgh jlkashdjkl gfhloashdfgh jkladshjkgl haskl dhfiu hajkl fghuasbhfljbahuk bfkljabwehrf bajkls bflaskdjf ljakdfk
</span>
</span>
</p>
The following styles are applied:
#p {
border-bottom: 1px solid black;
text-align: justify;
}
#span1 {
display: block;
margin-bottom: -1px;
}
#span2 {
border-bottom: 1px solid black;
}
Let's start from the inside here...
#span2 is given a bottom border in order to create the bulk of the lined-paper look. If we stop here, however, we have a problem: The lines don't extend all the way to the right margin, as has been mentioned previously. This issue we'll get to in a moment.
#span1, wrapping #span2, is 50% of the solution to this too-short line problem. I've given it a display property of block, which will allow me to apply a -1px bottom margin, effectively "covering up" the last overhanging line of #span2 with the bottom edge of #span1. The effect of this isn't worth much until we get to...
#p Here the styles we've applied to #span1 pay off. First, we have text-align: justify which takes care of most of the bottom-border lines reaching the right margin, save of course for the last line, which now looks really out of place. To take care of this, we apply border-bottom: 1px solid black to #p which -- because of the -1px bottom margin on our block-styled #span1 -- overlaps the last, short bottom border and completes the illusion.
Yes, it's sort of kludgy, but when it comes down to the wire and the client's demands can't be adjusted, sometimes a kludge is what you need.
(Note: I wouldn't expect this to work for email formatting... Like I said before, it's something I needed for mimicking that lined-paper look on a printed page.)
Unless I am mistaken, you want something like this:
http://jsfiddle.net/eB6tY/
CSS:
#postcard .line
{
width: 100%;
border-bottom: 1px solid #000;
}
HTML:
<div id="postcard">
<div class="line">Line 1</div>
<div class="line">Line 2</div>
<div class="line">Line 3</div>
</div>
in your lines that you need to underline add a style="border-bottom: 1px solid #000"(probably on your containing td)
Maybe Im missing the point but could you not do
<u> my text here </u>
assuming DIV as your relevant selector
div{text-decoration:underline}
or inline if you are emailing this...
<div style='text-decoration:underline'>
You could use a background image with the height of one line of text (plus margin-bottom) and width 1 pixel. The content will be "transparent plus a dot for the place where the line should go"...
This came up in my search so I will post my solution to my problem. I needed to underline an a tag that had padding to the end of line that; problem was the underline would start at begining of the element and not the text.
Problem:
Solution:
menu .heading a {
color: #414142 ;
}
.menu .heading a:after {
/* to get a nice underline that starts at padding-left offset */
border-bottom: 2px solid #414142;
content: '';
display: block;
position: relative;
bottom: -0.5em;
}

Resources