• Triangle Down         • Triangle Left              • Triangle Right
  • Triangle Top-Left     • Triangle Top-Right     • Triangle Bottom-Left
  • Triangle Bottom-Right

Various triangle shapes with CSS, created only with a sinlge DIV tag and a few CSS properties.

Triangle Up

Code:
<style type="text/css">
#triangleup {
 width: 0;
 height: 0;
 border-left: 50px solid transparent;
 border-right: 50px solid transparent;
 border-bottom: 100px solid blue;
}
</style>

<div id="triangleup"><br/><br/><br/>>UP</div>
Demo:



UP

Triangle Down

Code:
<style type="text/css">
#triangledown {
 width: 0;
 height: 0;
 border-left: 50px solid transparent;
 border-right: 50px solid transparent;
 border-top: 100px solid blue;
}
/* For the content in triangle */
#triangledown div{ margin:-85px 0 0 -20px; }
</style>

<div id="triangledown"><div>DOWN</div></div>
Demo:
DOWN

Triangle Left

Code:
<style type="text/css">
#triangleleft {
 width: 0;
 height: 0;
 border-top: 50px solid transparent;
 border-bottom: 50px solid transparent;
 border-right: 100px solid blue;
}
/* For the content in triangle */
#triangleleft div{ margin:-10px 0 0 25px; }
</style>

<div id="triangleleft"><div>LEFT</div></div>
Demo:
LEFT

Triangle Right

Code:
<style type="text/css">
#triangleright {
 width: 0;
 height: 0;
 border-top: 50px solid transparent;
 border-bottom: 50px solid transparent;
 border-left: 100px solid blue;
}
/* For the content in triangle */
#triangleright div{ margin:-10px 0 0 -85px; }
</style>

<div id="triangleright"><div>RIGHT</div></div>
Demo:
RIGHT

Triangle Top-Left

Code:
<style type="text/css">
#triangletopleft {
 width: 0;
 height: 0;
 border-top: 100px solid blue;
 border-right: 50px solid transparent;
}
</style>

<div id="triangletopleft">...</div>
Demo:
...

Triangle Top-Right

Code:
<style type="text/css">
#triangletopright {
 width: 0;
 height: 0;
 border-top: 100px solid blue;
 border-left: 50px solid transparent;
}
</style>

<div id="triangletopright">...</div>
Demo:
...

Triangle Bottom-Left

Code:
<style type="text/css">
#trianglebottomleft {
 width: 0;
 height: 0;
 border-bottom: 100px solid blue;
 border-right: 50px solid transparent;
}
</style>

<div id="trianglebottomleft">...</div>
Demo:
...

Triangle Bottom-Right

Code:
<style type="text/css">
#trianglebottomright {
 width: 0;
 height: 0;
 border-bottom: 100px solid blue;
 border-left: 50px solid transparent;
}
</style>

<div id="trianglebottomright">...</div>
Demo:
...

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which attribute is used in <img> tag for the address of the image?
href src rel
<img src="http://coursesweb.net/imgs/webcourses.gif" width="191" height="63" alt="Courses-Web" />
Which CSS code hides the element on page?
display: none; display: inline; position: relative;
#id {
  display: none;
}
What instruction stops the execution of a while() or for() statement?
continue prompt() break
for(var i = 0; i< 8; i++) {
  if(i > 1) break;
  alert(i);
}
Indicate the function that can create a constant.
define() include() defined()
define("CONSTANT_NAME", "value");
echo CONSTANT_NAME;
Triangles with CSS

Last accessed pages

  1. JavaScript code and PHP (13817)
  2. dompdf (1718)
  3. jQuery plugin for Image SlideShow Carousel - Feature Carousel 2 (1343)
  4. Read Excel file data in PHP - PhpExcelReader (38034)
  5. Ajax-PHP File Manager (3049)

Top accessed pages

  1. Courses Web: PHP-MySQL JavaScript Ajax HTML CSS Flash-AS3 (49620)
  2. Read Excel file data in PHP - PhpExcelReader (38034)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (36948)
  4. Get Attribute (ID, Class, Name, Title, Src) with jQuery (33324)
  5. PHP PDO - exec (INSERT, UPDATE, DELETE) MySQL (30696)