Solved

Dotted border has extra pixel in Firefox

Posted on 2007-11-14
4
674 Views
Last Modified: 2013-12-07
When using a dotted border on only one edge of a DIV, Firefox always puts a dot at both ends of the line, even if the pattern would normally call for a space. I'm guessing it does this to make sure the border is the right width, but I'd like it to give the pattern higher priority.

Paste the code below into an HTML file and you'll see what I mean. IE7 renders the pattern right, but the line is only 99 pixels long, which is fine by me. Opera alters the number of spaces between the dots in a best-effort approach to get the pattern and size right. Firefox, though, will have two dots at the end of the line.

Anybody know how to get Firefox to leave off that last dot, short of making sure all my border lengths are an odd number of pixels (which I can't guarantee with dynamic content).
<html>
 

<head>

<style>
 

DIV.bottom {

   border-bottom: 1px dotted black;

   width: 100px;

}
 

DIV.right {

   border-right: 1px dotted black;

   width: 10px;

   height: 100px;

}
 

</style>

</head>
 

<body>
 

<div class="bottom"></div>

&nbsp;

<div class="right"></div>
 

</body>
 

</html>

Open in new window

0
Comment
Question by:EmmDub
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
TheKyle earned 500 total points
ID: 20285616
I don't think there's any way of modifying how firefox renders the dots.  The only alternative solution that I can think of would be to create a 2x1 background image that has one black pixel and one white/transparent pixel and then tile the image to get a dotted line effect.

By the way, the dotted lines in IE6 and below actually turn out as a dashed line.  So, you may want to take that into consideration.
0
 

Author Comment

by:EmmDub
ID: 20285649
Yeah, I declared IE6 a lost cause ages ago. We've tried using the background image trick like you suggested, but we ran into issues when we wanted to have the dotted line as a separator and have a background color on the div itself. We worked around it by just adding more divs, but more elegance would be sweet.
0
 
LVL 6

Expert Comment

by:TheKyle
ID: 20285669
You could give the div a background color and the image.  Maybe something like this...
div

{

    background: blue url(dottedline.gif) repeat-x left bottom;

    border: none;

    padding-bottom: 25px;

    margin-bottom: 25px;

}

Open in new window

0
 

Author Comment

by:EmmDub
ID: 20290559
Thanks for the info. I'll accept your first comment because, in this case, "you can't" seems to be the right answer.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
text align center the options is an html select 4 39
jQuery detect if it is a mobile device 3 104
CSS Question 9 42
Unwanted gap in IE11 between header and menu 9 20
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now