Trying to flip a triangle css - css

Been trying to follow and play with this fiddle: http://jsfiddle.net/bossy_nova/wBUW7/1/
I've been looking for a way to get this kinda triangle to become a downward facing triangle. Played with the rotations, and that didn't prove useful. Am I missing something?
So how do I flip this arrow? Thanks for you help in advance.
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 0px 0px -2px rgba(0,0,0,0.5);
}
.triangle-with-shadow:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background: #999;
transform: rotate(45deg);
-ms-transform:rotate(45deg); /* IE 9 */
-moz-transform:rotate(45deg); /* Firefox */
-webkit-transform:rotate(45deg); /* Safari and Chrome */
-o-transform:rotate(45deg); /* Opera */
top: 25px;
left: 25px;
box-shadow: -1px -1px 10px 0px rgba(0,0,0,0.5);
}​

Your transformations need to be in your main CSS, not in the :after state:
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 16px 10px -15px rgba(0,0,0,0.5);
transform: rotate(180deg);
-ms-transform:rotate(180deg); /* IE 9 */
-moz-transform:rotate(180deg); /* Firefox */
-webkit-transform:rotate(180deg); /* Safari and Chrome */
-o-transform:rotate(180deg); /* Opera */
}

Rotate a triangle 360 degrees from
http://www.identifydesign.net/tutorials/css/triangles-circles/
<style type="text/css">
.triangle2{
width:0;
height:0;
border-top:20px solid #000;
border-left:20px solid transparent;
border-right:20px solid transparent;
-webkit-transform:rotate(360deg);
}
</style>
<div class="triangle"></div>

Just apply the rotate transform to the main element. You'll also want to apply some margin to bring the top edge back into JSFiddle's field of view.
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 0px 0px -2px rgba(0,0,0,0.5);
transform: rotate(180deg);
-ms-transform:rotate(180deg); /* IE 9 */
-moz-transform:rotate(180deg); /* Firefox */
-webkit-transform:rotate(180deg); /* Safari and Chrome */
-o-transform:rotate(180deg); /* Opera */
margin-top: 15px;
}
.triangle-with-shadow:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background: #999;
transform: rotate(45deg);
-ms-transform:rotate(45deg); /* IE 9 */
-moz-transform:rotate(45deg); /* Firefox */
-webkit-transform:rotate(45deg); /* Safari and Chrome */
-o-transform:rotate(45deg); /* Opera */
top: 25px;
left: 25px;
box-shadow: -1px -1px 10px 0px rgba(0,0,0,0.5);
}​
JSFiddle

You could use the above answers or you could change the positioning...
.triangle-with-shadow {
width: 100px;
height: 50px;
position: relative;
overflow: hidden;
box-shadow: 0 -16px 10px -15px rgba(0,0,0,0.5);
}
.triangle-with-shadow:after {
content: "";
position: absolute;
width: 50px;
height: 50px;
background: #999;
transform: rotate(45deg);
-ms-transform:rotate(45deg); /* IE 9 */
-moz-transform:rotate(45deg); /* Firefox */
-webkit-transform:rotate(45deg); /* Safari and Chrome */
-o-transform:rotate(45deg); /* Opera */
top: -25px;
left: 25px;
box-shadow: -1px -1px 10px 0px rgba(0,0,0,0.5);
}​

Related

how to use data-* for tooltip for ellipses element

I have a span which contains ellipses and i want to show the content through tooltip, but the position of the tooltip isn't seem to adjust as i can't apply position relative to the parent (due to ellipses). Here's the code i've tried
.data-tooltip:hover:before{
content: "";
width: 0;
height: 0;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-bottom: 5px solid rgba(0, 0, 0, 0.6);
position: absolute;
bottom: 82%;
left: 25%;
-webkit-transform: translate(-58%, 41.5%);
transform: translate(-58%, 51.5%);
}
.data-tooltip:hover:after{
content: attr(data-title);
padding: 6px 8px;
color: #fff;
text-align: left;
text-decoration: none;
background-color: rgba(0, 0, 0, 0.6);
border-radius: 4px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
min-height: 32px;
word-wrap: break-word;
position: absolute;
top: unset;
bottom: 75%;
-webkit-transform: translate(-50%, 50%);
transform: translate(-50%, 50%);
}
<span class="data-tooltip" data-tooltip="my tooltip">
ellipsed content
</span>
Here i am using 'before' for tooltip arrow and 'after' for tooltip content, but their positions doesn't seem to adjust either.
i have tried positioning my data-tooltip content relative, but due to overflow:hidden, the tooltip cuts outside the box.
An example below...
This code quoted from Chris Bracco. Please look at this article for detail.
/* Add this attribute to the element that needs a tooltip */
[data-tooltip] {
position: relative;
z-index: 2;
cursor: pointer;
}
/* Hide the tooltip content by default */
[data-tooltip]:before,
[data-tooltip]:after {
visibility: hidden;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
pointer-events: none;
}
/* Position tooltip above the element */
[data-tooltip]:before {
position: absolute;
bottom: 150%;
left: 50%;
margin-bottom: 5px;
margin-left: -80px;
padding: 7px;
width: 160px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background-color: #000;
background-color: hsla(0, 0%, 20%, 0.9);
color: #fff;
content: attr(data-tooltip);
text-align: center;
font-size: 14px;
line-height: 1.2;
}
/* Triangle hack to make tooltip look like a speech bubble */
[data-tooltip]:after {
position: absolute;
bottom: 150%;
left: 50%;
margin-left: -5px;
width: 0;
border-top: 5px solid #000;
border-top: 5px solid hsla(0, 0%, 20%, 0.9);
border-right: 5px solid transparent;
border-left: 5px solid transparent;
content: " ";
font-size: 0;
line-height: 0;
}
/* Show tooltip content on hover */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after {
visibility: visible;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
<p style="margin-top:50px">
<span data-tooltip="I’m the tooltip text.">I’m a span with a tooltip.</span>
</p>
Instead of
data-tooltip="my tooltip"
Your data-tooltip attribute should be data-title
That should work now.

Double sided arrow on a div

Im looking to generate a double sided arrow on a div. I was able to generate on the 'after' but before is not working. How can I do it?
div {
width: 5px;
height: 220px;
background-color: red;
/* Rotate div */
-ms-transform: rotate(30deg);
/* IE 9 */
-webkit-transform: rotate(30deg);
/* Chrome, Safari, Opera */
transform: rotate(30deg);
transform-origin: bottom left;
position: relative;
}
div:after {
content: '';
position: absolute;
top: 0;
left: 0;
border-style: solid;
transform: translate(-40%, -50%);
border-width: 0 10px 20px 10px;
border-color: transparent transparent red transparent;
}
div:before {
content: '';
position: absolute;
top: 0;
left: 0;
border-style: solid;
transform: translate(-40%, -50%);
border-width: 0 10px 20px 10px;
border-color: transparent transparent red transparent;
}
<div></div>
View on JSFiddle
You have the same rule for both :before and :after. Just adjust it sligtly and you're golden.
div {
width: 5px;
height: 220px;
background-color: red;
/* Rotate div */
-ms-transform: rotate(30deg);
/* IE 9 */
-webkit-transform: rotate(30deg);
/* Chrome, Safari, Opera */
transform: rotate(30deg);
transform-origin: bottom left;
position: relative;
}
div:before,
div:after {
content: '';
position: absolute;
left: 0;
border-style: solid;
border-color: red transparent;
}
div:after {
top: 0;
transform: translate(-40%, -50%);
border-width: 0 10px 20px 10px;
}
div:before {
bottom: 0;
transform: translate(-40%, 50%);
border-width: 20px 10px 0 10px;
}
<div></div>
Hi have update your fiddle:
https://jsfiddle.net/p6tryx79/1/
div {
width: 5px;
height: 120px;
background-color: red;
/* Rotate div */
-ms-transform: rotate(30deg);
/* IE 9 */
-webkit-transform: rotate(30deg);
/* Chrome, Safari, Opera */
transform: rotate(30deg);
transform-origin: bottom left;
position: relative;
margin-left:30px;
}
div:after {
content: '';
position: absolute;
top: 0;
left: 0;
border-style: solid;
transform: translate(-40%, -50%);
border-width: 0 10px 20px 10px;
border-color: transparent transparent red transparent;
}
div:before {
content: '';
position: absolute;
bottom: -6px;
left: -4px;
border-style: solid;
transform: rotate(60deg);
border-width: 0 10px 20px 10px;
border-color: transparent transparent red transparent;
}

Firefox, Opera position: absolute

This is a structure of my site:
<html>
<body>
<embed flash>
<div id='dialog'>
<div width="500px" height="300px"><iframe/></div>
</div>
</body>
</html>
<style type="text/css">
.hide { display: none; }
.show { display: block; }
iframe { border: 0; }
#dialog { background-color: rgba(0,0,0,0.5); position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 100; }
#dialog .dialog-inside { width: 650px; -webkit-box-shadow: 0px 0px 30px 0px rgba(50, 50, 50, 0.54); -moz-box-shadow: 0px 0px 30px 0px rgba(50, 50, 50, 0.54); box-shadow: 0px 0px 30px 0px rgba(50, 50, 50, 0.54); margin: auto; overflow: hidden; border-radius: 5px; }
#dialog .dialog-inside .dialog-header { position: absolute; right: 0; right: 1px; top: 3px; }
#dialog .dialog-inside .dialog-header .close { width: 23px; height: 23px; background: url("Images/close.png"); background-position: 2px 2px; background-repeat: no-repeat; border: 1px solid transparent; cursor: pointer; }
#dialog .dialog-inside .dialog-header .close:hover { background-color: #fdc985; border-color: #4040B1; }
#dialog .dialog-inside .dialog-bottom-wrapper { position: absolute; bottom: 0px; right: 0; left: 0; height: 42px; background-color: #f8f8f8; }
#dialog .dialog-inside .dialog-bottom-wrapper .dialog-bottom { float: right; margin: 8px 5px; }
#dialog .dialog-inside .dialog-bottom-wrapper .dialog-bottom .btn { background: rgb(251,251,249); /* Old browsers */ /* IE9 SVG, needs conditional override of 'filter' to 'none' */ background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZiZmJmOSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmM2YzZWYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); background: -moz-linear-gradient(top, rgba(251,251,249,1) 0%, rgba(243,243,239,1) 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(251,251,249,1)), color-stop(100%,rgba(243,243,239,1))); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, rgba(251,251,249,1) 0%,rgba(243,243,239,1) 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, rgba(251,251,249,1) 0%,rgba(243,243,239,1) 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, rgba(251,251,249,1) 0%,rgba(243,243,239,1) 100%); /* IE10+ */ background: linear-gradient(to bottom, rgba(251,251,249,1) 0%,rgba(243,243,239,1) 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fbfbf9', endColorstr='#f3f3ef',GradientType=0 ); /* IE6-8 */ border: 1px solid #7f9db9; color: #333333; cursor: pointer; display: inline-block; margin-left: .5em; padding: 0px 12px; text-align: center; line-height: 20px; outline: none; border-radius: 3px; }
#dialog .dialog-inside .dialog-bottom-wrapper .dialog-bottom .btn:hover { background-color: #d1d1d1; border-color: #d1d1d1; color: #111; moz-transition: background-position 0.1s linear; ms-transition: background-position 0.1s linear; o-transition: background-position 0.1s linear; text-decoration: none; transition: background-position 0.1s linear; webkit-transition: background-position 0.1s linear; outline: none; }
#dialog iframe { display: block; height: 114px; }
</style>
The problem is dialog I set it position: absolute, left, top, bottom, right: 0, in Chrome, IE work fine, it's rendered full screen with black background. Opera, the dialog has width and height is fix with div child => it doesn't have fullscreen. In firefox, it like the same, but I hover on dialog in Inspect Mode, it show black background.
Anyone has the problem like that?
Try adding
height: 100%;
width: 100%;
on #dialog

css gradient for triangle shaped arrow

Please take a look at http://jsfiddle.net/ghAgQ/
I need the same gradient for arrow, as it is for the rectangle. Any ideas how thats done? Thanks
.rectangle {
background-color: #EEE;
height: 80px;
width: 240px;
border: 1px solid #CCC;
background: white;
cursor: pointer;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,white), color-stop(37%,#F1F1F1), color-stop(57%,#E1E1E1), color-stop(100%,#F6F6F6));
float: left;
}
.arrow {
border-top: 41px solid transparent;
border-bottom: 41px solid transparent;
border-left: 15px solid #C4C4C4;
float: left;
cursor: pointer;
}
​
You can do this in a much simpler way, using just an element and a rotated pseudo element (any browser that supports CSS gradients also supports CSS transforms and pseudo-elements) with an angled linear gradient. Also, don't use the old WebKit syntax (see this bit about the history of the syntax).
Working in current versions of Chrome, Opera, Firefox, IE on Windows.
DEMO
HTML is just <div class='rectangle'></div>
Relevant CSS:
.rectangle {
float: left;
position: relative;
height: 80px;
width: 240px;
border: solid 1px #ccc;
border-right: none;
background: #eee linear-gradient(white, #f1f1f1 37%, #e1e1e1 57%, #f6f6f6);
cursor: pointer;
}
.rectangle:after {
position: absolute;
top: 16px; right: -25px;
width: 48px;
height: 47px;
border-left: solid 1px #ccc;
border-top: solid 1px #ccc;
transform: rotate(134deg) skewX(-10deg) skewY(-10deg);
background: #eee linear-gradient(45deg, white, #f1f1f1 37%, #e1e1e1 57%, #f6f6f6);
content: '';
}
Edit January 2013
4 months later, I have a slightly improved solution. This time, the values are computed. The first time I got them using trial and error.
new demo
.shape {
float: left;
position: relative;
border: 1px solid #ccc;
border-right: none;
width: 240px; height: 80px;
background: linear-gradient(white, #f1f1f1 37%, #e1e1e1 57%, #f6f6f6);
cursor: pointer;
}
.shape:after {
position: absolute;
top: 50%; right: 0;
margin: -24px -20px;
border-top: solid 1px #ccc;
border-right: solid 1px #ccc;
width: 40px /* 80px/2 */; height: 47px/* 80px/sqrt(3) */;
transform: rotate(30deg) skewY(30deg); /* create a rhombus */
/* 49.1deg = atan(1.15) = atan(47px/40px) */
background:
linear-gradient(-49.1deg, #f6f6f6, #e1e1e1 43%, #f1f1f1 63%, white);
content: ''
}
<div class='shape'></div>
While the demo above looks really nice in Chrome, any browser support information is missing and it does not work in many browsers. I have spend some time to develop a more cross-browser approach.
HERE'S A SOLUTION FOR ALL MODERN BROWSERS WITH A NICE BUILD FUNCTION USING SASS
.triangle {
/* sample positioning */
width: 160px;
height: 160px;
position: absolute;
top: 30%;
left: 45%;
/*
* deprecated syntax has better browser support
* IE8+
* http://css-tricks.com/almanac/properties/c/clip/
*/
clip: rect(auto, 180px, auto, 100px);
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.triangle::after {
content: "";
position: absolute;
top: 10px;
bottom: 10px;
left: 10px;
right: 10px;
/**
* To also support IE 9 we you a background images
* as fallback, created via compass:
* #include background-image(linear-gradient(300deg, green, blue));
*/
background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjEuMDkxNTA2IiB5MT0iMC44NDE1MDYiIHgyPSItMC4wOTE1MDYiIHkyPSIwLjE1ODQ5NCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwODAwMCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwMDBmZiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
background-size: 100%;
background-image: -moz-linear-gradient(150deg, green, blue);
background-image: -webkit-linear-gradient(150deg, green, blue);
background-image: linear-gradient(300deg, green, blue);
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
Currently supports IE 10+, Firefox, Opera, Chroma, Safari

CSS: Menu Bar and content styling issues

I am currently adding a navigation bar to a web page. But I am running into some css styling issues. The navigation menu bar is pushing the content below, leaving a huge gap in between and making it uneven. I took the precaution in leaving out anything that will mess with the bottom like margin bottom-padding but I am still getting the same result. How can I get the menu bar to not affect the content below? EXAMPLE
With the Navigation bar added:
Without navigation bar the contents below are even:
I have added the specific css rules that are causing the issue to devgrow.css:
<style>
#navigation {
position:relative;
top:-45px;
left:450px;
}
#au_title {
color: #FC821D;
font-size: 120%;
font-weight: bold;
left: 515px;
letter-spacing: 2px;
position: relative;
text-transform: uppercase;
top: -105px;
}
#searchInput {
left: 700px;
position: relative;
top: -180px;
}
#contentNav { color: #cfdae3; }
/* Dark Button CSS */
.buttonNav {
outline: 0;
padding: 5px 12px;
display: block;
color: #EBEBEB;
font-weight: bold;
text-shadow: 1px 1px #1f272b;
border: 1px solid #1c252b;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
background: #232B30; /* old browsers */
background: -moz-linear-gradient(top, #3D4850 3%, #313d45 4%, #232B30 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#3D4850), color-stop(4%,#313d45), color-stop(100%,#232B30)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3D4850', endColorstr='#232B30',GradientType=0 ); /* ie */
box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* CSS3 */
-moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Firefox */
-webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Safari, Chrome */
}
.buttonNav:hover {
color: #fff;
background: #4C5A64; /* old browsers */
background: -moz-linear-gradient(top, #4C5A64 3%, #404F5A 4%, #2E3940 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#4C5A64), color-stop(4%,#404F5A), color-stop(100%,#2E3940)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4C5A64', endColorstr='#2E3940',GradientType=0 ); /* ie */
}
.buttonNav:active {
background-position: 0 top;
position: relative;
top: 1px;
color: #fff;
padding: 6px 12px 4px;
background: #20282D; /* old browsers */
background: -moz-linear-gradient(top, #20282D 3%, #252E34 51%, #222A30 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#20282D), color-stop(51%,#252E34), color-stop(100%,#222A30)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#20282D', endColorstr='#222A30',GradientType=0 ); /* ie */
-moz-box-shadow: 1px 1px 1px rgba(255,255,255,0.1); /* Firefox */
-webkit-box-shadow: 1px 1px 1px rgba(255,255,255,0.1); /* Safari, Chrome */
box-shadow: 1px 1px 1px rgba(255,255,255,0.1); /* CSS3 */
}
/* Other stuff: */
.button-list { list-style: none; width: 100%; float: left; display: block; }
.button-list li { float: left; margin: 0 5px 0 0; }
.button-list li.search { padding-left: 18px; margin-left: 10px; position: relative; }
/* Search CSS: */
.search-input {
padding: 0 5px 0 22px;
border: 2px solid #DADADA;
height: 30px;
font-size: 12px;
line-height: 30px;
border-radius: 25px;
-moz-border-radius: 25px;
-webkit-border-radius: 25px;
background: #FFF; /* old browsers */
}
.search-input:focus {outline: none;}
.search-submit {
width: 13px;
height: 13px;
border: none;
background: url(images/mag-glass.png) no-repeat;
display: block;
position: absolute;
left: 26px;
top: 10px;
text-indent: -9999em;
}
</style>
First i have say that the coding is really bad. For fixed that issue remove float from you button-list. Write like this :
.button-list {
list-style: none outside none;
overflow: hidden;
}
Hey now define overflow hidden in your css #contentArea id
as like this
#contentArea {
overflow: hidden;
}
Add style clear both in css of first content area
<div id="contentArea" style="clear:both">

Resources