Related
Hello I'm trying to make a series of windows with icons as the background but my current css looks like this for each rectangle but whenever i add the icon into the div it will not appear ever. Any suggestions?
` margin:30px;
padding-bottom: 15%;
/*
border-width: 1px;
border: solid;
border-color: -webkit-linear-gradient(left, #4100db 0%,#3b128e 24%);
border-radius: 5px;
color: #FFF;
*/
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-left: 2px solid #384395;
border-right: 2px solid #6F3B97;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background-position: 0 0, 0 100% ;
background-repeat: no-repeat;
-webkit-background-size: 100% 2px;
-moz-background-size: 100% 2px;
background-size: 100% 2px;
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgMSAxIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIj48bGluZWFyR3JhZGllbnQgaWQ9Imxlc3NoYXQtZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiMzYWNmZDUiIHN0b3Atb3BhY2l0eT0iMSIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzNhNGVkNSIgc3RvcC1vcGFjaXR5PSIxIi8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2xlc3NoYXQtZ2VuZXJhdGVkKSIgLz48L3N2Zz4=),url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgMSAxIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJub25lIj48bGluZWFyR3JhZGllbnQgaWQ9Imxlc3NoYXQtZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPjxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiMzYWNmZDUiIHN0b3Atb3BhY2l0eT0iMSIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzNhNGVkNSIgc3RvcC1vcGFjaXR5PSIxIi8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2xlc3NoYXQtZ2VuZXJhdGVkKSIgLz48L3N2Zz4=);
background-image: -webkit-linear-gradient(left, #384395 0%, #6F3B97 100%), -webkit-linear-gradient(left, #384395 0%, #6F3B97 100%);
background-image: -moz-linear-gradient(left, #384395 0%, #3a4ed5 100%), -moz-linear-gradient(left, #384395 0%, #6F3B97 100%);
background-image: -o-linear-gradient(left, #384395 0%, #6F3B97 100%), -o-linear-gradient(left, #384395 0%, #6F3B97 100%);
background-image: linear-gradient(to right, #384395 0%, #6F3B97 100%), linear-gradient(to right, #384395 0%, #6F3B97 100%);
`
How can I align the text in the button to the bottom?
I tried to set line-height and vertical-align: bottom; in my CSS but neither worked.
UPDATE:
Also, I want the text to be in front of the background. I have set back gradients in the normal, hover and active states, so I my white text to be in front of that.
Code:
.img-panel {
position: relative;
height: 300px;
width: 100%;
background-size: cover;
color: white;
}
.img-panel:after {
content: "";
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(40%, rgba(0, 0, 0, 0)), color-stop(100%, #000000));
background: -moz-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, #000000 100%);
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, #000000 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, #000000 100%);
}
.img-panel:hover:after {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0.3)), color-stop(40%, rgba(0, 0, 0, 0.3)), color-stop(100%, #000000));
background: -moz-linear-gradient(top, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.3) 40%, #000000 100%);
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.3) 40%, #000000 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.3) 40%, #000000 100%);
}
.img-panel:active:after {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0.6)), color-stop(40%, rgba(0, 0, 0, 0.6)), color-stop(100%, #000000));
background: -moz-linear-gradient(top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.6) 40%, #000000 100%);
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.6) 40%, #000000 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.6) 40%, #000000 100%);
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div class="row">
<div class="col-md-4 img-panel-container">
<button class="img-panel translucent-overlay-light" style="background-image: url('http://placeimg.com/500/300/any')">
Hello
</button>
</div>
</div>
For some reason bootstrap is not working in the code snippet
You can create a child element in your button (here a span) that you position to the bottom of the button.
Because the button is position: relative, the span with position: absolute will be position according to the button.
We also create a child element to display the background, via the ::before pseudo-element selector.
To resolve which child will be display on top, between two position: absolute elements, the browser use the HTML/DOM order. So a ::before element will be displayed below the others, while a ::after will be displayed on top.
You also can force the stacking order with the z-index property.
.img-panel {
position: relative;
height: 300px;
width: 100%;
background-size: cover;
}
.img-panel::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
background: linear-gradient(to bottom, transparent 40%, black 100%);
}
.img-panel:hover::before {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 40%, black 100%);
}
.img-panel > span {
position: absolute;
left: 0; right: 0; bottom: 0;
text-align: center;
color: white;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<button class="img-panel translucent-overlay-light" style="background-image: url('http://placeimg.com/500/300/any')">
<span>Hello</span>
</button>
You could use vertical-align: bottom; but to do this you need to apply a display:table to the container and display:table-cell to the button and give him some specific height.
Take a look to this examples: http://daker.me/2014/04/4-css-tricks-for-vertical-alignment.html
Try adding this:
<style>
span{
position: absolute;
bottom: 0;
}
</style>
And in html markup add:
<span>Hello</span>
Try this
.img-panel {
display: flex;
flex-direction: column-reverse;
align-items: center;
}
If your button's height is 300px, you can try with a padding-top property :
CSS:
.img-panel {
position: relative;
height: 300px;
width: 100%;
background-size: cover;
color: white;
padding-top:250px;
}
Bootply : http://www.bootply.com/AHSl2MVDIy
Place your button text in a span, give it absolute positioning and set bottom to 0:
See the .img-panel span.button-title rule.
Update:
To place the text above the background, just add a higher z-index for the button text. A low number will do it.
.img-panel {
position: relative;
height: 300px;
width: 100%;
background-size: cover;
color: white;
}
.img-panel:after {
content: "";
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(40%, rgba(0, 0, 0, 0)), color-stop(100%, #000000));
background: -moz-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, #000000 100%);
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, #000000 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 40%, #000000 100%);
}
.img-panel:hover:after {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0.3)), color-stop(40%, rgba(0, 0, 0, 0.3)), color-stop(100%, #000000));
background: -moz-linear-gradient(top, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.3) 40%, #000000 100%);
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.3) 40%, #000000 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.3) 40%, #000000 100%);
}
.img-panel:active:after {
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, rgba(0, 0, 0, 0.6)), color-stop(40%, rgba(0, 0, 0, 0.6)), color-stop(100%, #000000));
background: -moz-linear-gradient(top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.6) 40%, #000000 100%);
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.6) 40%, #000000 100%);
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.6) 40%, #000000 100%);
}
.img-panel span.button-title {
position: absolute;
bottom: 0;
z-index: 10;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div class="row">
<div class="col-md-4 img-panel-container">
<button class="img-panel translucent-overlay-light" style="background-image: url('http://placeimg.com/500/300/any')">
<span class="button-title">Hello</span>
</button>
</div>
</div>
I'm trying to add a gradient to my CSS background image. I've found a bunch of other post relating to having a gradient background, with an image sitting on top, but I would like the image itself to be a gradient. I tried this:
body {
margin: 0;
width: 100%;
height: 100%;
font-family: rexlia;
background-size: cover;
background: -moz-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%), url(cubes.jpg) no-repeat;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 0, 0, 0)), color-stop(59%, rgba(0, 0, 0, 0)), color-stop(100%, rgba(0, 0, 0, 0.65))), url(cubes.jpg) no-repeat;
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%), url(cubes.jpg) no-repeat;
background: -o-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%), url(cubes.jpg) no-repeat;
background: -ms-linear-gradient(top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%), url(cubes.jpg) no-repeat;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.65) 100%), url(cubes.jpg) no-repeat;
}
All this does however is display the unmodified image. This snippit actually came from another post, in which apparently it worked. Doesn't for me though. Can anybody shed some light on this? Thanks.
I'm guess that is this is the only code you are using then you've omitted to make the html element 100% tall so that the body can also be 100% tall.
html {
height: 100%;
}
body {
margin: 0;
width: 100%;
min-height: 100%;
background-size: cover;
background-image: linear-gradient(to bottom, rgba(255, 0, 0, .5) 0%, rgba(255, 0, 0, .5) 59%, rgba(0, 0, 255, 0.65) 100%), url(http://lorempixel.com/image_output/technics-q-c-640-480-2.jpg);
}
JSfiddle Demo
if you remove margin:0; it works and gradient strippes image(because of that defaut margin body starts to fill html), or add html{height:100%;} it works.
html or body background mixe together if not set in both tags
some test so you can see and understand behavior
body {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.75) 100%), url(http://lorempixel.com/300/200/abstract/10) center no-repeat;
background-size: cover, cover;
}
html:hover body {
margin: 4em;
/* gradient is repeated and takes margin value as reference to repeat itself in html background */
}
if body has content or a valid height fixed, it works the same way
body {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 59%, rgba(0, 0, 0, 0.75) 100%), url(http://lorempixel.com/300/200/abstract/10) center no-repeat;
background-size: cover, cover;
}
html:hover body {
margin: 4em;
/* gradient is repeated body's height and keeps being repetead in html background*/
height: 100px;
if you add html, body {height:100%;} then body has a valid height.
html, body {height:100%;}
body {
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0, 0) 59%, rgba(0, 0, 0, 0.75) 100%), url(http://lorempixel.com/300/200/abstract/10) center no-repeat;
background-size: cover, cover;
}
and finally, if you give a background value to html, body will hold its own background within itself.
html{background:lime;}
body {
padding:2em;
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0, 0) 59%, rgba(0, 0, 0, 0.75) 100%), url(http://lorempixel.com/300/200/abstract/10) center no-repeat;
background-size: cover, cover;
}
Is there any way that I can have 4 different colours on one side of a border in CSS? I currently have
#header
{
border-color:#88a9eb;
}
I want to have a border of 4 solid colours, with a 25% split on each, Is this something that is possible?
I want to make a solid version of this without the white bits in between.
You can use the border-image property to create a gradient border with 4 colors. Normally gradients move gradually from one color to another and it produces a blur like effect but setting the color-stops (the percentage values) such that the end-point of one color is same as the starting point of the next color makes the colors come to a hard stop and thus end up producing block like effects.
The border can be set to the required side by changing the border-image-width and the direction of the gradient. For example, top & bottom borders would need the gradient to go from left to right while left & right borders would need the gradient to go from top to bottom.
The gradients use percentage values for the size (and color-stop) and hence they are responsive by default and can adapt automatically even if the container's dimensions change.
The only drawback to using border-image is the poor browser support for this property at present. IE10- do not support this property.
.bordered-top {
border-image: linear-gradient(to right, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
border-image-slice: 1;
border-image-width: 4px 0px 0px 0px;
}
.bordered-bottom {
border-image: linear-gradient(to right, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
border-image-slice: 1;
border-image-width: 0px 0px 4px 0px;
}
.bordered-left {
border-image: linear-gradient(to bottom, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
border-image-slice: 1;
border-image-width: 0px 0px 0px 4px;
}
.bordered-right {
border-image: linear-gradient(to bottom, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
border-image-slice: 1;
border-image-width: 0px 4px 0px 0px;
}
div {
height: 100px;
width: 300px;
padding: 10px;
background: beige;
margin: 10px;
}
<!-- library added only for old browser support -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div class='bordered-top'>Border only on top</div>
<div class='bordered-bottom'>Border only on bottom</div>
<div class='bordered-left'>Border only on left</div>
<div class='bordered-right'>Border only on right</div>
For IE10+ support, you could mimic the same behavior by using gradients for the background-image property instead of border-image like in the below snippet.
Unlike with border-image, here the side on which the border is applied cannot be controlled using the border-image-width and we have to use background-position instead to position the image at the required position.
The background-size determines the thickness of the border. For top & bottom borders, the size in x-axis should be 100% and that in y-axis is the thickness of the border. For left & right borders, the size in y-axis should be 100% and that in x-axis is the thickness of the border.
.bordered-top {
background-image: linear-gradient(to right, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
background-size: 100% 4px;
background-repeat: no-repeat;
background-position: 0% 0%;
}
.bordered-bottom {
background-image: linear-gradient(to right, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
background-size: 100% 4px;
background-repeat: no-repeat;
background-position: 0% 100%;
}
.bordered-left {
background-image: linear-gradient(to bottom, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
background-size: 4px 100%;
background-repeat: no-repeat;
background-position: 0% 0%;
}
.bordered-right {
background-image: linear-gradient(to bottom, rgb(139, 191, 64) 25%, rgb(230, 27, 33) 25%, rgb(230, 27, 33) 50%, rgb(124, 196, 236) 50%, rgb(124, 196, 236) 75%, rgb(254, 181, 17) 75%);
background-size: 4px 100%;
background-repeat: no-repeat;
background-position: 100% 0%;
}
div {
height: 100px;
width: 300px;
padding: 10px;
background: beige;
margin: 10px;
}
<!-- library added only for old browser support -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div class='bordered-top'>Border only on top</div>
<div class='bordered-bottom'>Border only on bottom</div>
<div class='bordered-left'>Border only on left</div>
<div class='bordered-right'>Border only on right</div>
You can use box-shadow and after psuedo-element to do this
What I did:
I first created an :after element on the bottom, then added box-shadows horizontally with different colors
If you want to change the strength of the border simply give more height to the :after element
div {
width: 200px;
height: 100px;
position: relative;
background: grey;
}
div:after {
bottom: 0;
position: absolute;
content: "";
width: 50px;
height: 5px;
background: green;
box-shadow: 50px 0 0 0 red, 100px 0 0 0 orange, 150px 0 0 0 green;
}
<div></div>
Same thing on a larger div will be like this
div {
width: 500px;
height: 100px;
background: orange;
position: relative;
}
div:after {
bottom: 0;
position: absolute;
content: "";
width: 100px;
height: 5px;
background: green;
box-shadow: 100px 0 0 0 darkred, 200px 0 0 0 red, 300px 0 0 0 yellow, 400px 0 0 0 tomato;
}
<div></div>
I have taken what harry had and amended it to suit my needs. I now have:
border-image: linear-gradient(to right, #8CC63F 0%, #006F3B 25%, #ED1C24 25%, #9B1B1E 50%, #85CDEC 50%, #217EC2 75%, #FFC20E 75%, #F04E23 100%);
border-image-slice: 3;
border-image-width: 0px 0px 4px 0px;
border-image-repeat: round;
This is the best solution for my needs.
Complicated but cool solution: Use SVG (e.g. <svg> tag), add 4 paths, assign different stroke-dasharray and stroke-color attributes.
Simpler and still cool solution: Try border-image. (See Harry's answer)
Very simple solution if you just need one border: Create an image, but it as the background image, repeat it only on one axis, position it at the edge of the container, e.g. (for bottom border)
.container {
background-image: url(image.png);
background-repeat: repeat-x;
background-position: bottom left;
}
you can try this one:
.solid{
width: 300px;
border-image: linear-gradient(to right, red 25%, blue 25%, blue 50%, green 50%, green 75%, orange 75%);
border-image-slice: 4;
}
DEMO
Best solution is with linear-gradient. Definitely.
But someone who's the beginner in this could find this solution useful. By using 2-3-4 colors or even more, this is the right way to do them. Not the best solution for this question, but maybe someone while reading this wants to understand better how do the colors with borders work.
<html>
<head>
<style>
p.one {
border-style: solid;
border-color: #0000ff;
}
p.two {
border-style: solid;
border-color: #ff0000 #0000ff;
}
p.three {
border-style: solid;
border-color: #ff0000 #00ff00 #0000ff;
}
p.four {
border-style: solid;
border-color: #ff0000 #00ff00 #0000ff rgb(250,0,255);
}
</style>
</head>
<body>
<p class="one">One-colored border!</p>
<p class="two">Two-colored border!</p>
<p class="three">Three-colored border!</p>
<p class="four">Four-colored border!</p>
</body>
</html>
I have piece of CSS code which works fine in Firefox but not in Chrome.
I guess made a mistake when using -webkit-linear-gradient which shows invalid value in chrome
HTML code:
<div class="laptop">
<div class="glare-xl"></div>
<div class="screen-xl">
<img src="http://www.psdgraphics.com/file/silver-laptop-icon.jpg" alt="laptop" />
</div>
<div class="base-xl"></div>
<div class="addons-xl "></div>
<div class="button-xl"></div>
</div>
CSS code:
.laptop:before {
background: none repeat scroll 0 0 padding-box #d3d4d6;
border-color: #cecece #b7b7b9 #5e5d62;
border-radius: 12px 12px 0 0;
border-style: solid;
border-width: 1px;
bottom: 0;
content: "";
height: 317px;
left: 0;
margin-bottom: -1px;
margin-left: -6px;
margin-top: -6px;
position: absolute;
top: 0;
width: 536px;
z-index: -3;
}
.laptop:after {
background: none repeat scroll 0 0 padding-box #000000;
border: 1px solid #bdbec0;
border-radius: 10px 10px 0 0;
bottom: 0;
content: "";
height: 311px;
left: 1px;
margin-bottom: -1px;
margin-left: -5px;
margin-top: -6px;
position: absolute;
top: 2px;
width: 532px;
z-index: -2;
}
.laptop {
background: none repeat scroll 0 0 padding-box #010101;
border: 1px solid #101113;
border-radius: 8px 8px 0 0;
display: inline-block;
height: 230px;
margin-bottom: 40px;
margin-left: 60px;
position: relative;
width: 528px;
}
.glare-xl {
background-clip: padding-box;
background-image: -moz-linear-gradient(-27% bottom , rgba(0, 0, 0, 0.1) 55%, rgba(0, 0, 0, 0.1) 55%, rgba(255, 255, 255, 0.25) 55.05%);
background-image: -webkit-linear-gradient(-27% bottom , rgba(0, 0, 0, 0.1) 55%, rgba(0, 0, 0, 0.1) 55%, rgba(255, 255, 255, 0.25) 55.05%);
background-image: -ms-linear-gradient(-27% bottom , rgba(0, 0, 0, 0.1) 55%, rgba(0, 0, 0, 0.1) 55%, rgba(255, 255, 255, 0.25) 55.05%);
background-image: -o-linear-gradient(-27% bottom , rgba(0, 0, 0, 0.1) 55%, rgba(0, 0, 0, 0.1) 55%, rgba(255, 255, 255, 0.25) 55.05%);
background-image: linear-gradient(-27% bottom , rgba(0, 0, 0, 0.1) 55%, rgba(0, 0, 0, 0.1) 55%, rgba(255, 255, 255, 0.25) 55.05%);
border-radius: 7px 7px 0 0;
height: 308px;
position: absolute;
top: -1px;
width: 610px;
z-index: 100;
}
.screen-xl:before {
background: -moz-linear-gradient(center top , #303235 0%, #0a0a0a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -webkit-linear-gradient(center top , #303235 0%, #0a0a0a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -ms-linear-gradient(center top , #303235 0%, #0a0a0a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -o-linear-gradient(center top , #303235 0%, #0a0a0a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: linear-gradient(center top , #303235 0%, #0a0a0a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
border-color: #000000;
border-radius: 7px 7px 0 0;
border-style: solid;
border-width: 9px 7px;
content: "";
height: 272px;
left: -6px;
position: absolute;
top: -5px;
width: 500px;
z-index: 3;
}
.screen-xl:after {
background: -moz-linear-gradient(center top , #5c5c5c 0%, #656565 8%, #4f4f4f 42%, #727272 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -webkit-linear-gradient(center top , #5c5c5c 0%, #656565 8%, #4f4f4f 42%, #727272 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -ms-linear-gradient(center top , #5c5c5c 0%, #656565 8%, #4f4f4f 42%, #727272 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -o-linear-gradient(center top , #5c5c5c 0%, #656565 8%, #4f4f4f 42%, #727272 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: linear-gradient(center top , #5c5c5c 0%, #656565 8%, #4f4f4f 42%, #727272 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
border: 1px solid #404040;
border-radius: 25px;
box-shadow: 0 0 2px #ffffff;
content: "";
height: 3px;
left: 49%;
position: absolute;
top: -8px;
width: 3px;
z-index: 130;
}
.screen-xl {
border: 1px solid #141414;
border-radius: 2px 2px 0 0;
height: 276px;
left: 10px;
position: absolute;
top: 12px;
width: 502px;
}
.screen-xl img {
border-radius: 2px;
height: 272px;
left: 0;
margin-left: 1px;
margin-top: 4px;
position: absolute;
width: 500px;
z-index: 100;
}
.base-xl:before {
background: -moz-linear-gradient(center top , #c5c4c6 0%, #aeadb1 6%, #99989d 25%, #98979d 31%, #918f96 38%, #686a6d 63%, #4c5254 75%, #43484a 81%, #2c2f30 94%, #16191a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -webkit-linear-gradient(center top , #c5c4c6 0%, #aeadb1 6%, #99989d 25%, #98979d 31%, #918f96 38%, #686a6d 63%, #4c5254 75%, #43484a 81%, #2c2f30 94%, #16191a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -ms-linear-gradient(center top , #c5c4c6 0%, #aeadb1 6%, #99989d 25%, #98979d 31%, #918f96 38%, #686a6d 63%, #4c5254 75%, #43484a 81%, #2c2f30 94%, #16191a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -o-linear-gradient(center top , #c5c4c6 0%, #aeadb1 6%, #99989d 25%, #98979d 31%, #918f96 38%, #686a6d 63%, #4c5254 75%, #43484a 81%, #2c2f30 94%, #16191a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: linear-gradient(center top , #c5c4c6 0%, #aeadb1 6%, #99989d 25%, #98979d 31%, #918f96 38%, #686a6d 63%, #4c5254 75%, #43484a 81%, #2c2f30 94%, #16191a 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
border-radius: 0 0 400px 400px / 0 0 100px 100px;
bottom: -15px;
box-shadow: 7px 0 3px #6a6d71 inset, -7px 0 3px #6a6d71 inset;
content: "";
height: 15px;
left: -1px;
position: absolute;
width: 655px;
z-index: 130;
}
.base-xl {
background: -moz-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #e3e3e5 14%, #e3e3e5 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -webkit-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #e3e3e5 14%, #e3e3e5 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -ms-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #e3e3e5 14%, #e3e3e5 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -o-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #e3e3e5 14%, #e3e3e5 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #e3e3e5 14%, #e3e3e5 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
border-color: #6b6e72;
border-radius: 3px 3px 0 0;
border-style: solid;
border-width: 1px 1px 0;
bottom: -101px;
box-shadow: 0 1px 2px #ffffff inset;
float: left;
height: 22px;
left: -125px;
margin-left: 60px;
position: absolute;
width: 654px;
z-index: 4;
}
.addons-xl:before {
background-color: #000000;
border-radius: 55px 55px 5px 5px;
bottom: -115px;
content: "";
height: 5px;
left: 4%;
position: absolute;
width: 5px;
z-index: 1000;
}
.addons-xl:after {
background-color: #000000;
border-radius: 55px 55px 5px 5px;
bottom: -115px;
content: "";
height: 5px;
position: absolute;
right: 4%;
width: 5px;
z-index: 1000;
}
.addons-xl {
background-color: rgba(0, 0, 0, 0);
border-radius: 10px;
height: 3px;
margin-left: 53%;
margin-top: 5px;
width: 3px;
z-index: 1000;
}
.button-xl:after {
background: -moz-linear-gradient(center top , #1a2226 0%, #535a61 64%, #68778c 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -webkit-linear-gradient(center top , #1a2226 0%, #535a61 64%, #68778c 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -ms-linear-gradient(center top , #1a2226 0%, #535a61 64%, #68778c 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -o-linear-gradient(center top , #1a2226 0%, #535a61 64%, #68778c 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: linear-gradient(center top , #1a2226 0%, #535a61 64%, #68778c 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
border-radius: 10px;
bottom: -6px;
box-shadow: 0 0 1px #ffffff;
content: "";
height: 3px;
left: 274px;
position: absolute;
width: 20px;
z-index: 4;
}
.button-xl {
background: -moz-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #b1b3b6 14%, #b1b3b6 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -webkit-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #b1b3b6 14%, #b1b3b6 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -ms-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #b1b3b6 14%, #b1b3b6 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: -o-linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #b1b3b6 14%, #b1b3b6 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
background: linear-gradient(left center , #979ba0 1%, #dfdfdf 4%, #f2f2f2 6%, #b1b3b6 14%, #b1b3b6 86%, #f2f2f2 94%, #dfdfdf 96%, #6a6d71 100%) repeat scroll 0 0 padding-box rgba(0, 0, 0, 0);
border-color: #5c6064;
border-radius: 0 0 50px 50px;
border-style: solid;
border-width: 0 1px 1px;
bottom: -87px;
box-shadow: 0 1px 5px #ffffff, 0 1px 1px #ffffff inset;
content: "";
height: 6px;
left: 44%;
position: absolute;
width: 60px;
z-index: 4;
}
Questions:
1)Why CSS doesn't work in Chrome
2)How I can make this all structure i.e laptop as responsive as I tried max-width at all places but it doesn't work?
JS FIDDLE
You need to remove/replace the center keyword in the linear-gradient() function. According to CSS3 specs there is no such thing.