Css Course

  • 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 specifies the HTTP method (GET, POST) used to submit the form-data?
action method value
<form action="script.php" method="post"> ... </form>
Which CSS property allows to add shadow to boxes?
background-image box-shadow border-radius
#id {
  background-color: #bbfeda;
  box-shadow: 11px 11px 5px #7878da;
}
Which function removes the first element from an array?
pop() push() shift()
var fruits = ["apple", "apricot", "banana"];
fruits.shift();
alert(fruits.length);           // 2
Indicate the function that can be used to check if a PHP extension is instaled.
function() filetype() extension_loaded()
if(extension_loaded("PDO") === true) echo "PDO is available."
Triangles with CSS

Last accessed pages

  1. PHP Script Website Mini-Traffic (7281)
  2. innerHTML and outerHTML to Get and Replace HTML content (30658)
  3. Mysql SELECT JOIN tables on two different Databases (4523)
  4. Date and Time in ActionScript 3 (10112)
  5. CSS Trapezoid Shape (11425)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (120)
  2. CSS cursor property - Custom Cursors (13)
  3. PHP Unzipper - Extract Zip, Rar Archives (13)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (12)
  5. JavaScript trim, rtrim and ltrim (11)