pseudo:before not taking background property in chrome - css

The pseudo :before works on Firefox, Safari but not in Chrome.
Its a square box rotated to form a diamond shape. But, using :before the bg is again rotated backwards and given a position fixed. It gives a really nice effect !
Check My Site :
www.wangeltmg.com
When you scroll at first, the background overlaps and creates blurry image to get cleared.. !
All i did is
#element3
{
width: 1000px;
height:1000px;
line-height: 5em;
margin: 0px auto;
border: 0px solid #666;
border-radius: 3px;
margin-top:150px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
overflow: hidden;
left:0; right:0;
top:10%;
}
#element3:before
{
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -10%;
z-index: 0;
background: url(../img/custom11.jpg) 0 0 no-repeat fixed;
background-size:135% 135%;
background-position:140px -315px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
Is there anything to work on regarding the compatibility with Chorme ?
I would love to have your answers fellas.
Thanks.

Your CSS background is behaving bizarre on chrome because you needed to add:
-webkit-transform CSS 3 transform with prefix for Chrome.
.parallax-two #element3 {
border: 0 solid #666666;
border-radius: 3px;
height: 1000px;
left: 0;
line-height: 5em;
margin: 150px auto 0;
overflow: hidden;
position: absolute;
right: 0;
top: 10%;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
width: 1000px;
}
http://fiddle.jshell.net/mmvdz/6
http://fiddle.jshell.net/mmvdz/6/show/
For Firefox, Chrome, Opera, IE etc. it is preferred to add the vendor prefix CSS3 versions as well. It is needed for older versions of Firefox as well for example.
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
If you use editor like Sublime Text to code manually. You have plugins which add this vendor prefix automatically.
http://www.hongkiat.com/blog/css-automatic-vendor-prefix/
I do see that you have another problem on Chrome. The fixed div has issues with z-index. And it seems it has to do with CSS 3 transform properties for webkit which makes the triangle appear above the fixed div but without the blur effect in Chrome.
#home-wrap {
-webkit-backface-visibility: hidden;
}

Related

How to fix: I created an "X" using css only but in ie11 it moves when clicked

I created an X button using CSS only. It displays fine in all browsers besides on ie11. In ie11 the button stacks over a border but when it's clicked it moves slightly down to the correct place it's suppose to be. I have no clue on how to fix this and have tried a bunch of different ways. This code is scss btw.
button {
width: 50px;
height: 50px;
right: 15px;
top: 15px;
padding: 0;
position: absolute;
border: none;
background-color: transparent;
&:hover { cursor: pointer; }
&:before, &:after {
content: '';
width: 100%;
height: 2px;
background-color: blue;
display: block;
position: absolute;
}
&:before {
-webkit-transform: rotateZ(45deg);
-moz-transform: rotateZ(45deg);
-ms-transform: rotateZ(45deg);
transform: rotateZ(45deg);
}
&:after {
-webkit-transform: rotateZ(-45deg);
-moz-transform: rotateZ(-45deg);
-ms-transform: rotateZ(-45deg);
transform: rotateZ(-45deg);
}
}
}
I would use a media query plus a position property plus an !important (not recommended but we want to be absolutely sure) to forbid the button from moving anywhere if the browser is ie10 or higher. The code I would use would be something like this:
#media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { /*media query for ie10+*/
button {
position:absolute !important;
}
}
Failing that, there is another question here which also mentions jumping elements but that was from ie8. The issue was solved by using display:block.
What version of IE11 are you using? The code runs well in my IE11 which version is 11.116.18362.0. I made a simple demo:
button {
width: 50px;
height: 50px;
right: 15px;
top: 15px;
padding: 0;
position: absolute;
border: none;
background-color: transparent; }
button:hover {
cursor: pointer; }
button:before, button:after {
content: '';
width: 100%;
height: 2px;
background-color: blue;
display: block;
position: absolute; }
button:before {
-webkit-transform: rotateZ(45deg);
-moz-transform: rotateZ(45deg);
-ms-transform: rotateZ(45deg);
transform: rotateZ(45deg); }
button:after {
-webkit-transform: rotateZ(-45deg);
-moz-transform: rotateZ(-45deg);
-ms-transform: rotateZ(-45deg);
transform: rotateZ(-45deg); }
<link rel="stylesheet" type="text/css" href="demo-style.css">
<button></button>
I use your scss to compile it down to css file and then import it into the page. The 'X' won't move in IE11. If you're using older version of IE11, I suggest that you could move to the latest version and try it again.

background videos shake on safari and firefox

I add some videos to my website and when I tested on Chrome it's working correctly, but when I tested on safari and Firefox it shakes. What is the problem?
This is my CSS code:
.parallax-background video {
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
When I read about this problem I think the problem in this part
transform: translate(-50%,-50%);
But I don't know how I can fix it.
Try this code
.parallax-background video {
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
-moz-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}

should i use css for this background image

I'm trying to find out if it's possible to replicate this background with CSS.
I thought about using a skew (similar to the example below) but not having much luck so far.
http://jsfiddle.net/EA3RY/
#chevron {
position: relative;
text-align: center;
padding: 12px;
margin-bottom: 6px;
height: 60px;
width: 200px;
}
#chevron:before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 51%;
background: #ccc;
-webkit-transform: skew(0deg, 6deg);
-moz-transform: skew(0deg, 6deg);
-ms-transform: skew(0deg, 6deg);
-o-transform: skew(0deg, 6deg);
transform: skew(0deg, 6deg);
}
#chevron:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 50%;
background: #ccc;
-webkit-transform: skew(0deg, -6deg);
-moz-transform: skew(0deg, -6deg);
-ms-transform: skew(0deg, -6deg);
-o-transform: skew(0deg, -6deg);
transform: skew(0deg, -6deg);
}
I guess my question #1 is it possible? and #2 is it good practice to use CSS in this situation? Maybe I'm just better off using a background image.
I don't think transform is the right tool for this job; it's a lot of work for the browser to do just to render a shape like that.
Alternative I'd suggest considering:
linear-gradient.
CSS Gradients can do a lot more than just easing from one colour to another. You can draw all kinds of patterns with them. Here's a page with some examples you might want to look at. None of them are exactly what you're looking for, but they do demonstrate some of the things you can do with gradients which you might not have appreciated.
SVG.
Using an SVG image for your background gives you complete flexibility over how it looks. Basically it's an image; it can be anything. But an SVG for an image like this should be pretty light-weight in terms of filesize, and you can include it directly in the CSS code as a data URL. Quick and easy.
I gave it a shot. It looks fine on Chrome and IE, but not in Firefox. Problem is any content you place in the top and bottom parts will appear in the same spot as the middle.
<div class="fancy-up"></div>
<div class="fancy">content in here!</div>
<div class="fancy-down"></div>
c
.fancy {
background-color: #FFA500;
height: 100px;
width: 500px;
}
.fancy-up {
border-right: 500px solid #FFA500;
border-top: 30px solid rgba(0, 0, 0, 0);
height: 0;
width: 0;
}
.fancy-down {
border-bottom: 30px solid rgba(0, 0, 0, 0);
border-right: 500px solid #FFA500;
height: 0;
width: 0;
}
Fiddle
Reference

How to show text within icon

I am new to web development (and self taught) so please excuse if this is a dumb question.
How do I show text inside an icon? Such as number inside a heart etc.
I assuming for this purpose webfont icon will not work?
Is using CSS shapes is better for thus purpose - so that it will render when resized etc?
Or is vector better option.
Here is the CSS for heart that I was planning to use. But I am not clear as how to display text inside.
.heart {
position: relative;
width: 100px;
height: 90px;
}
.heart:before,
.heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #fc2e5a;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
.heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
trans.orm-origin :100% 100%;
}
Thanks in advance!
Here is my solution
I inserted a span between the div tags. That way, like mbratch said, you can set the z-index property as a higher value. This, along with position:absolute, will give you what you are looking for.
I used jQuery to vertically center it, in case you wanted multiple lines of text

CSS rotate moves DIV from side of page

I'm trying to create a side tag, as found here in it basic form. http://www.firstforturf.co.uk/quotation.php
I'm trying to do as much of it as possible using CSS rather than just putting in an image however I've encountered a problem.
Upon rotating the side DIV it is moved from the side of the page. I've tried setting the margin to 0 but it doesn't seem to be working.
If it helps, here are the CSS rules for sidetag.
color: #FFF;
height: 50px;
width: 200px;
position: fixed;
background-color: rgb(0,102,204);
font-size: 32px;
line-height: 50px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
text-align: center;
top: 50%;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
writing-mode: tb-rl;
Greatful if anyone could help. Cheers.
Use transform-origin:
-moz-transform-origin: 20px;
-ms-transform-origin: 20px;
-o-transform-origin: 20px;
-webkit-transform-origin: 20px;
transform-origin: 20px;
Take a look at -webkit-transform-origin. As your element is fixed, you may need to amend the transform origin accordingly.
You can use transform-orign:
transform: rotate(45deg);
transform-origin:20% 40%;
-ms-transform: rotate(45deg); /* IE 9 */
-ms-transform-origin:20% 40%; /* IE 9 */
-webkit-transform: rotate(45deg); /* Safari and Chrome */
-webkit-transform-origin:20% 40%; /* Safari and Chrome */
-moz-transform: rotate(45deg); /* Firefox */
-moz-transform-origin:20% 40%; /* Firefox */
-o-transform: rotate(45deg); /* Opera */
-o-transform-origin:20% 40%; /* Opera */
try this link

Resources