2

Hi guys i'm trying to create this(image) css border around a div, but having trouble.

I have created the border but cannot get the border to be smooth. here is my code

border-left: 5px solid #036;
border-right: 5px solid #036;
border-top: 10px solid #036;
border-bottom: 5px solid #036;
Raju Kumar
  • 1,255
  • 3
  • 21
  • 39

4 Answers4

3

Fiddle Up, You can see it here.

Hope it help.

EDIT:

Html:

<div class="a">
    <span class="abs">Title here?</span>
    <div class="b">
        Hello.                
    </div>
</div>​

Css:

div.a {
    border-top: 10px solid #333;
    border-left: 5px solid #333;
    border-bottom: 5px solid #333;
    border-right: 5px solid #333;
    border-radius: 10px;
    background-color: #333;
    width: 200px;
    height: 400px;
}
div.b {
    border-radius: 5px;
    background-color: #FFF;
    width: 180px;
    height: 350px;
    padding: 10px;
}

.abs {
    color: #FFF;
    display: inline-block;
    font-weight: bold;
    margin-bottom: 10px;
}
Andrea Turri
  • 6,480
  • 7
  • 37
  • 63
2

You can attain such a setup using new CSS3 facilities, namely border-radius and gradient form of background image. You can find information about those all around the internet, for example background gradient and border radius.

Below is example, it will not work in all browsers, and is not exactly what you want, but it should be enough to give you the basic idea:

The html structure could look like this:

<div id="big_div">
    Search for a hotel
    <div id="small_white_div">
    Some other content
    </div>
</div>

And the corresponding css would be:

#big_div {height:450px;width:250px;border-radius: 5px;background-color:red;
background-image: linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209) 51%,
rgb(33,51,140) 100%);
background-image: -o-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209) 51%,
rgb(33,51,140) 100%);
background-image: -moz-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209)    
51%, rgb(33,51,140) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209)
51%, rgb(33,51,140) 100%);
background-image: -ms-linear-gradient(bottom, rgb(33,51,140) 5%, rgb(125,187,209) 51%, 
rgb(33,51,140) 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.05, rgb(33,51,140)),
color-stop(0.51, rgb(125,187,209)),
color-stop(1, rgb(33,51,140))
);}
#small_white_div {height:400px;width:220px;margin:auto;border-radius:5px;
background-color:white;margin-top:20px;}

Good luck.

Atheus
  • 94
  • 1
  • 7
1

It's done with background image.

Popcorn
  • 49
  • 1
0

You are looking for border-radius to get the rounded corners. Try out something like this:

-webkit-border-radius: 8px 8px 8px 8px;
-moz-border-radius: 8px 8px 8px 8px;
border-radius: 8px 8px 8px 8px;

Note this is CSS3 and will not work in older versions of IE

Josh Mein
  • 28,107
  • 15
  • 76
  • 87