Why doesn't the css `rotateY` property work on safari - html

Below is my html and css code. It is pretty simple. I want to show a square \F1FC on a red react.
.parent::before {
position: absolute;
content: '';
width: 40px;
height: 40px;
background-color: red;
border-radius: 10px 0px 0px 10px;
transform: perspective(5px) rotateY(-2deg);
z-index: -1;
}
p::before {
content: "\F1FC";
color: black;
margin-left: 15px;
}
<div class="parent">
<p></p>
</div>
This code works fine on chrome but doesn't work on safari. Half of the square is hidden by the p::before. Below is a screen shot on safari:
Below is the screenshot for chrome:

This is some kind of weird bug in Safari and pseudo elements. My solution for this issue was to counter the transform: rotateY(-2deg); on the parent pseudo element since it was causing the issue.
Add display: block; and transform: rotateY(1deg); to p::before. The small rotation doesn't seem to affect how the square looks and it fixes it for me in Safari.
.parent::before {
position: absolute;
content: '';
width: 40px;
height: 40px;
background-color: red;
border-radius: 10px 0px 0px 10px;
transform: perspective(5px) rotateY(-2deg);
z-index: -1;
}
p::before {
content: "\F1FC";
color: black;
display: block;
margin-left: 15px;
transform: rotateY(1deg);
}
<div class="parent">
<p></p>
</div>

Related

CSS showing different render behavior on different zoom level

I created this Tooltip element using HTML and CSS. But after a while I realized that the pointer of my tooltip is getting cut. At first I thought it was some overflow issue but it wasn't. Then I tried to change the zoom level of my chrome and I got this
ZOOM LEVEL <= 250%
As you can see the pointer of the tooltip (highlighted in red) is getting cut.
ZOOM LEVEL => 250%
Now, as you can see the same tooltip on different zoom level worked or rendered just fine.
Anyone can tell me what is the actual problem behind all this or this is a browser issue??
CODE FOR TOOLTIP
<div class="tooltip">
<div class="tooltip-pointer" data-pointer-direction="bottom"></div>
<div class="tooltip-content">Hello, World!</div>
</div>
.tooltip {
position: absolute;
color: white;
max-width: 196px;
font-weight: 600;
user-select: none;
border-radius: 4px;
font-size: 0.875rem;
pointer-events: none;
word-wrap: break-word;
transform-origin: 50% 0;
letter-spacing: 0.03125rem;
background-color: #18191c;
will-change: opacity, transform;
box-shadow: 0 5.18px 10.36px -3.89px rgba(0, 0, 0, 0.25);
.tooltip-pointer {
width: 0;
height: 0;
position: absolute;
pointer-events: none;
border: 5px solid transparent;
border-top-color: #18191c;
&[data-pointer-direction='bottom'] {
top: 100%;
left: 50%;
margin-left: -5px;
}
}
}
UPDATE
I haven't found any solution though instead what I did I change the pointer of tooltips from HTML to SVG after doing this the tooltip arrows or pointers is not getting cut on different zoom level or any zoom level. If anyone want the code DM me.
Why don't you try creating the down arrow in a different way? Something like this: https://jsfiddle.net/2jwhnrm3/
HTML
<div class="tooltip-pointer"></div>
<div class="tooltip">
<div class="tooltip-content">Hello, World!</div>
</div>
CSS
.tooltip {
position: absolute;
color: white;
max-width: 196px;
font-weight: 600;
user-select: none;
border-radius: 4px;
font-size: 0.875rem;
pointer-events: none;
word-wrap: break-word;
transform-origin: 50% 0;
letter-spacing: 0.03125rem;
background-color: #18191c;
will-change: opacity, transform;
box-shadow: 0 5.18px 10.36px -3.89px rgba(0, 0, 0, 0.25);
}
.tooltip-pointer {
border: solid red;
background: red;
border-width: 0 3px 3px 0;
display: inline-block;
position: absolute;
padding: 5px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
top: 17px;
left: 50px;
margin-left: -5px;
}

Create angled elements using html and css only

How to create the offer div with a background color using html and css only ?
What I'm asking is width and height of the offer div should be same as in picture.
I created this using html and CSS. However part of div is hidden in my solution because offer div has a larger width and height.
Code I have written :
.offer-text-wrapper {
display: inline-block;
position: absolute;
top: -39px;
left: -36px;
color: #FFF;
height: 72px;
width: 75px;
background: #f44336;
transform: rotate(-43deg);
}
.offer-text {
-moz-transform: rotate(-40deg);
-o-transform: rotate(-40deg);
display: inline-block;
margin-left: 21px;
line-height: 124px;
}
<div class="offer-text-wrapper">
<span class="offer-text"> Offer </span>
</div>
Edit :
Because width and height of offer-text-wrapper is larger, I'm having below issue when I added that to the bootstrap grid.
Have a look at the code snippet, it's basically just changing dimensions and position until you're happy with it.
Is this what you mean?
.offer-container { /* added container to show effect better */
width: 200px;
height: 100px;
overflow: hidden;
position: relative;
border: 1px solid #ccc;
border-radius: 12px;
margin: 40px;
}
.offer-text-wrapper {
display: inline-block;
position: absolute;
top: -29px;
left: -40px;
color: #FFF;
height: 72px;
width: 95px;
background: #f44336;
transform: rotate(-45deg);
text-align: center;
}
.offer-text {
display: inline-block;
line-height: 114px;
}
<div class="offer-container">
<div class="offer-text-wrapper">
<span class="offer-text">Offer</span>
</div>
</div>

CSS transform porperty Safari

I am trying to get following output (a large slash line between two numbers):
Following code works on Firefox and Chrome but doesn't work on Safari. Would there be any workaround for that?
Here's the code:
HTML:
<div class="wrap">
<div class="top">4</div>
<div class="bottom">15</div>
</div>
CSS:
.top {
display: block;
float: left;
font-size: 60px;
font-weight: 700;
}
.bottom {
display: block;
float: left;
font-size: 38px;
font-weight: 700;
margin-top: 70px;
position: relative;
width: 28px;
}
.bottom:before {
border-left: 1px solid;
content: "";
height: 66px;
position: absolute;
right: 0;
top: -35px;
transform: skew(-45deg);
transform-origin: left top 0;
width: 0;
}
JSFiddle Demo:
http://jsfiddle.net/pg4sxrc1/
Certain versions of Safari still require the use of the -webkit- prefix for transform and transform-origin, try adding the following definitions to your .bottom:before CSS:
-webkit-transform: skew(-45deg);
-webkit-transform-origin: left top 0;
jsFiddle Demo

How to create css headers for bootstrap div's

I'm trying to make the div for bootstrap to look like below not sure how you do it with css. The arrow and the section labeleled movies
Please view the pic at https://plus.google.com/+SamuelMuiruri/posts/fMMhNQwPbCm
First of all you have to position the title "Movies" about the description. The arrow is a only a little css magic
HTML:
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="specialbox">
<img src="https://placeimg.com/320/240/tech"/>
<div class="specialbox__description">
<span class="specialbox__title">Movies</span>
<h2>Age of Ultron</h2>
<p>Tony Stark tries ti jumpstart a dormant peace-kepping program...</p>
</div>
</div>
</div>
</div>
</div>
CSS:
.specialbox {
border: 3px solid #ccc;
}
.specialbox img {
width: 100%;
}
.specialbox__description {
position: relative; /* You need this, to position the title element absolute to the description */
padding: 20px 10px;
}
.specialbox__title {
position: absolute;
background-color: yellow;
text-transform: uppercase;
padding: 10px;
border-radius: 10px 10px 0 0;
top: -40px; /* Adjust to the height of the title container */
}
/* Magic described here */
.specialbox__title:after {
position: absolute;
display: block;
content: '';
width: 30px;
height: 30px;
border: 15px solid transparent;
left: 50%;
bottom: -30px;
margin-left: -15px;
border-top: 15px solid yellow;
}
http://jsfiddle.net/ytbtbt1d/
I think you want to create a TRIANGLE edge below the div containg the text -'MOVIES' (see screenshot below)
I have created a code for you here: JSFIDDLE
HTML:
<div>Movies</div>
CSS
div{
position: relative;
display:inline-block;
width: 140px;
padding: 10px;
background:#FFC000;
text-transform: uppercase;
font-size: 24px;
text-align: center;
}
div:after{
position: absolute;
width: 0;
height: 0;
border-bottom: 40px solid rgba(0, 0, 0, 0);
border-right: 40px solid #FFC000;
bottom: -15px;
left: 0;
right:0;
margin:auto;
content: '';
-ms-transform: rotate(135deg); /* IE 9 */
-webkit-transform: rotate(135deg); /* Chrome, Safari, Opera */
transform: rotate(135deg);
}

Css Triangle not rendering properly in IE

I am trying to create a css trianlge for the header navigation.I have achieved it but it is not rendering properly in IE.
Here is the Working Fiddle solution for the sample i have created.I have fixed the position but when i try to run in IE(Currently i have IE 11.0) the triangle is rendered as a square box but when i try to run it in Chrome and FF it is working fine.
Fiddler : http://jsfiddle.net/cKnyQ/20/
a:hover:after {
background: white;
border: solid black;
border-width: 1px 1px 0 0;
bottom: 0px;
content: ' ';
display: block;
height: 10px;
left: 32px;
position: absolute;
width: 10px;
z-index: 99;
-webkit-transform: rotate(-45deg);
-webkit-transform-origin: 50% 50%;
}
Use -ms-transform: rotate(-45deg)
Thanks Akshay mohite. As a side note i have edited the js fiddle with the searched solution.
Fiddle : http://jsfiddle.net/cKnyQ/25/
#Container a:hover::after {
content: "";
display: block;
border: 8px solid black;
border-bottom-color: white;
position: absolute;
bottom: 0px;
left: 50%;
margin-left: -12px;
background: white;
}