Two color border - html

I know it is possible to have the effect of a double border with one below the other but is it possible using css to have part of the width of a border one color and the rest another color?
Here is an example of an image that I would like to recreate as a border using css only:

I think I figured out one way to do it. Check this out http://jsfiddle.net/RE4A7/
html
<ul>
<li><h3>Mission</h3>
</li>
</ul>
css
ul h3 {
font-size:1.2em;
font-family:arial;
border-bottom:1px solid #333;
padding-bottom:10px;
position:relative;
width:250px;
}
ul li {
list-style:none;
}
ul h3:after {
border-bottom:1px solid #ff4800;
bottom:-1px;
left:0px;
content:"";
position:absolute;
width:55px;
}

UPDATE:
Seeing that the line in the post is actually a two colored line you can use the border-image property to achieve a similar effect (example showing only the principle but is not adjusted for perfect match):
ONLINE DEMO
CSS:
div {
border-top:0;
border-bottom:1px;
-webkit-border-image: -webkit-gradient(linear, left bottom, right bottom, from(#07f), to(#000), color-stop(0.3, #07f), color-stop(0.31, #000)) 21 20 30 21;
/* ... */
}
For other browsers:
-moz-border-image:
-webkit-border-image:
-o-border-image:
border-image: /* standard */
Note that the gradient parameter varies from browser to browser apparently so this need to be adjusted as well. Demo provided will only work with webkit browsers.
Old
Do you mean something like this:
For this you can use the following CSS:
.myClass {
height:40px;
width:60px;
border:5px solid #00a;
box-shadow:0 0 0 5px #f00 inset;
padding:5px;
}
Here the box.shadow set to inset with no blur acts as the second part of the border. The padding should prevent content from overlapping.
ONLINE DEMO

Related

Ugly edge when using gradient

I'm trying to create a 2 coloured background to use it as the background for my text container. To get two different colours I've used a gradient. Let me show you what it looks like now.
If you look closely, you can see the line in the middle looks kind of, I don't know what to call it, lets just say it doesn't look smooth.
Here's my css:
.btn {
background:#8a8a8a;
background: linear-gradient(to right bottom, #000000 50%, #8a8a8a 50%);
display:inline-block;
padding:0.75em 2.0em;
font-size:18px;
text-align:center;
margin:0.25em 0;
color:#ffffff;
font-weight:normal;
font-family:sans-serif;
}
Giving a small gap between the two color stops points (like 49.5% and 50.5%) did the trick.
You can try this style here: https://jsfiddle.net/dnn02d64/4/
.btn {
background:#8a8a8a;
background: linear-gradient(to right bottom, #000000 49.99%, #8a8a8a 50.99%);
display:inline-block;
padding:0.75em 2.0em;
font-size:18px;
text-align:center;
margin:0.25em 0;
color:#ffffff;
font-weight:normal;
font-family:sans-serif;
}

Why does the after pseudo element move an extra pixel when positioned absolutely in firefox?

http://jsfiddle.net/NgdUR/
im basically using css triangles made with borders to create a custom select box with both up and down arrows.
If you check this on opera, chrome, safari it works just fine, but in firefox there is an extra pixel on the after pseudo element (or one less pixel on the before) anyone know why this occurs?
If i change the pseudo elements to hold a background color they have no alignment issues:
http://jsfiddle.net/NgdUR/1/
any ideas?
Edit: image in firefox,
How i looks in other browsers:
Thanks
/Jai
I added a 1px height and width and changed the border width of each pseudo element to 2px. Does the trick in Firefox, IE9 and Chrome. IE8 and Opera 11+ looks a little chunky.
Updated fiddle
.test {
position:relative;
background:#ccc;
border:1px solid #aaa;
box-shadow:#aaa 0 0 4px;
display:block;
height:26px;
width:28px;
}
.test:before,
.test:after {
content:"";
border:2px solid transparent;
width:1px;
height:1px;
display:block;
position:absolute;
left:11px;
}
.test:before {
border-bottom:3px solid #000;
top:6px;
}
.test:after {
border-top:3px solid #000;
top:14px;
}​
this fixes it for me on FF11:
.test {
position:relative;
background:#ccc;
border:1px solid #aaa;
box-shadow:#aaa 0 0 4px;
display:block;
height:26px;
width:28px;
}
.test:before {
content:"";
border:3px solid transparent;
border-bottom:3px solid #000;
width:0;
height:0;
display:inline-block;
position:absolute;
top:6px;
left:11px;
}
.test:after {
content:"";
border:3px solid transparent;
border-top:3px solid #000;
width:0;
height:0;
display:inline-block;
position:absolute;
top:14px;
left:10px;
}
Well... A few years later and still the same issue: If you tell Firefox (speaking of version 45 at the moment) something with :before or :after and some game with thick border triangles, he still miscalculates the width and height of those elements randomly by up to one pixel. Which gives ugly visual annoyances, especially in the context of flowingly responsive layouts, when arrow heads and tails become separated from their body at half of all instances.
Having to fix those in one of my projects, i stumbled over this article. But it didn't actually help out of the box. Rather gave the idea to try completely other ways.
What reliably helped in my case was:
Set box-sizing of the triangle to border-box
Give the inner content of the triangle (width/height) size 0
Give the outer border-box the exact wanted size of the triangle
Relatively simple, but for Firefox the only way to get him into submission to the rules. Chrome didn't have any problem with any method of sizing. Opera, despite being a clone of Chrome, surprisingly showed the same clownery as Firefox, but also the same Taming.

transparency with iframe

im using iframe to desplay some pages that hold a gallerys and i added
2 divs that 1 of them is an arrow build by borders.
now when i try to see the 2 divs with the iframe the background on the div that holds the arrow is white i tryed to set the background color:
background-color:transparent;
but it didnt work.
is there any way to make the div background transparent?
i should add that the page that hold the iframe got an image.
this is the css of the arrow:
border-color: #ffffff #a0c7ff #ffffff #ffffff;
border-style: solid;
border-width: 37px;
width: 0px;
height: 0px;
You will need to add to the iframe:
allowTransparency="true"
[UPDATE]
The problem might be your arrow itself. You need to make the borders you don't want to see transparent instead of white. Compare these two:
http://jsfiddle.net/XtMCa/
And this (your CSS), which has a white background:
http://jsfiddle.net/XtMCa/1/
.transparent_div
{
width:400px;
height:180px;
margin:30px 50px;
background-color:#ffffff;
border:1px solid black;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
}

How to implement this button in HTML / CSS?

This is a button that has been originally implemented and styled in Silverlight.
How to implement this button in HTML/CSS? Note the different gradients in the border and the button background and also the rounder corners in the border. The border width should be adjustable but uniform size around the button.
The red colour in the example picture is page background, not part of the button.
Button screenshot http://i52.tinypic.com/2vsetlw.png
UPDATE: Forgot to mention, I would prefer a solution without images, ie. pure-css. Css3 is fine, I don't need to support IE6-8 for example.
I know it's not the most helpful thing to spoon-feed sometimes, but I had needed a break from work.
Demo: http://jsfiddle.net/wesley_murch/SzHQZ/
Looks nice in FF4 and Chrome, IE falls back to decent looking (though you could fix it with PIE).
Here's the CSS I used, I got the gradient code from some random online generator so it might not be optimal. There's too much contrast as well compared to your image, so just fine tune it.
<button>
<span>
Sign in
</span>
</button>
button {
border:0;
padding:3px;
background:#735544;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.18, #271D1B),
color-stop(0.59, #735544)
);
background-image: -moz-linear-gradient(
center bottom,
#271D1B 18%,
#735544 59%
);
border-radius:8px;
-moz-border-radius:8px;
-webkit-border-radius:8px;
}
--- Needed this break to get markdown to behave...
button span {
display:block;
color:#fff;
font:900 18px arial;
text-transform:uppercase;
padding:.35em 1.3em;
background:#382B25;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.18, #382B25),
color-stop(0.59, #C2A489)
);
background-image: -moz-linear-gradient(
center bottom,
#382B25 18%,
#C2A489 59%
);
border-radius:4px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
}
Looks like the boring version of http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba :)
you can take the example from there and just change the colors, probably want to replace
border-bottom: 1px solid #222;
with something like
border: 3px solid brown;
The example above uses an alpha-blended png for the gradient, but you can also go for css3 gradients, see http://css-tricks.com/examples/CSS3Gradient/ for a good cross-browser example.
Just save the image as a background
<input type="submit" class="btnSqueareInput" name="commit" value="SIGN IN"/>
btnSqueareInput {
background:transparent url(../images/sqaure.png) no-repeat;
border:medium none;
color:#FFFFFF;
cursor:pointer;
display:block;
font-family:Arial,Helvetica,sans-serif;
font-size:12px;
font-weight:bold;
height:32px;
margin:0;
padding:0;
text-align:center;
text-decoration:none;
vertical-align:top;
width:79px;
}
where square.png is rge image of the button w/o 'SIGN IN'

Background command not displaying/showing from the stylesheet when using date picker js

I'm new to this site having stumbled across it recently (and am loving it!) and was wondering whether someone can help me - I'm using Kelvin Luck's fantastic date picker and for some reason a background image is not behaving properly...
Here's the code straight from my CSS sheet:
a.dp-choose-date {
background: url (../calendar.png) no-repeat scroll 0 0 transparent;
display:block;
float:left;
height:16px;
margin:5px 3px 0;
overflow:hidden;
padding:0;
text-indent:-2000px;
width:16px;
}
however when the background image is viewed through firebug, firebug doesn't show the style for the background image at all:
a.dp-choose-date {
display:block;
float:left;
height:16px;
margin:5px 3px 0;
overflow:hidden;
padding:0;
text-indent:-2000px;
width:16px;
}
Would anyone have any ideas as to why this is happening? I've never seen this before!
The url by the way is http://www.s330042945.websitehome.co.uk/contact.php
Many thanks,
Andy
You need to remove the space between 'url' and the '('. This needs to be:
background: url(../calendar.png) no-repeat scroll 0 0 transparent;