Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim a small empty triangle on top of a div

Tags:

html

css

I'm trying to make a drop down menu, without any images, Pure CSS and HTML like the following: enter image description here

What I'm not able to do is make this little Triangle shaped trim on Top

is it possible in CSS, if it is, how?

like image 209
ImadBakir Avatar asked Feb 18 '23 06:02

ImadBakir


2 Answers

Live Example: http://jsbin.com/owafod/1/

I used CSS triangle generator to create the triangle.

#Nav { 
  width: 300px;
  height: 200px;
  background: #333;
}

#Triangle {
    width: 0px;
    height: 0px;
    border-style: solid;
    border-width: 10px 10px 0 10px;
    border-color: #ffffff transparent transparent transparent;
    margin: 0 auto;
}
like image 174
JSuar Avatar answered Feb 27 '23 16:02

JSuar


Here's a solution with borders :

Result :

enter image description here

HTML :

  <div id=a></div><div id=b></div>  
  <div id=c></div>

CSS :

#a {
  border-right: 5px solid white;
  border-bottom: 5px solid black;
  width: 100px;
  display: inline-block;
  margin:0;
}
#b {
  border-left: 5px solid white;
  border-bottom: 5px solid black;
  width: 100px;
  display: inline-block;
  margin:0;
}
#c {
   background: black; height:20px;width:210px
}

Tests


And here's a picture that will probably suffice to explain how it's made and how you can easily use this kind of border trick :

enter image description here

(the code to make it)

like image 24
Denys Séguret Avatar answered Feb 27 '23 17:02

Denys Séguret