I have to accomplish following image by using CSS:
It's one image which will contain the main-navigation. So I wrote some CSS in order to do so (not the correct color-codes, I know):
#menu-block {
background: #730868;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#730868), to(#0a9f9d));
background: -webkit-linear-gradient(top, #730868 0%, #0e70a2 76%,#0a9f9d 100%);
background: -moz-linear-gradient(top, #730868 0%, #0e70a2 76%,#0a9f9d 100%);
background: -ms-linear-gradient(top, #730868 0%, #0e70a2 76%,#0a9f9d 100%);
background: -o-linear-gradient(top, #730868 0%, #0e70a2 76%,#0a9f9d 100%);
background: linear-gradient(top, #730868 0%, #0e70a2 76%,#0a9f9d 100%);
-pie-background: linear-gradient(top, #730868 0%, #0e70a2 76%,#0a9f9d 100%);
behavior: url(/pie/PIE.htc);
}
And this code works great! It does what it has to do except for the arrow on the end... I honestly have no idea on how to tacle this issue.
Should I create a second div in the shape of an arrow and guess the closest color?
It should support IE8...
This gets you close
It actually ends up with a solid colored "point" (equal to the end color of the gradient). It might be possible to actually get a continuation of the gradient into the triangle if it absolutely needs to (I don't have time at present to figure that out).
Here's the example (note: the example uses code generated from colorzilla for IE9 support). You need to have a fixed width for this to work (to set the left/right border of the psuedo-element), but the height can be flexible. In my example, IE8 loses the red center. Perhaps with your PIE solution, it does not.
HTML (with IE9 condition as the example has)
<!--[if gte IE 9]>
<style type="text/css">
#menu-block {
filter: none;
}
</style>
<![endif]-->
<div id="menu-block" ></div>
CSS
#menu-block {
width: 100px;
position: relative;
background: rgb(0,0,255);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDBmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2ZmMDAwMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmMDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(0,0,255,1) 0%, rgba(255,0,0,1) 50%, rgba(255,255,0,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,255,1)), color-stop(50%,rgba(255,0,0,1)), color-stop(100%,rgba(255,255,0,1)));
background: -webkit-linear-gradient(top, rgba(0,0,255,1) 0%,rgba(255,0,0,1) 50%,rgba(255,255,0,1) 100%);
background: -o-linear-gradient(top, rgba(0,0,255,1) 0%,rgba(255,0,0,1) 50%,rgba(255,255,0,1) 100%);
background: -ms-linear-gradient(top, rgba(0,0,255,1) 0%,rgba(255,0,0,1) 50%,rgba(255,255,0,1) 100%);
background: linear-gradient(to bottom, rgba(0,0,255,1) 0%,rgba(255,0,0,1) 50%,rgba(255,255,0,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0000ff', endColorstr='#ffff00',GradientType=0 );
}
#menu-block:after {
content: '';
width: 0;
height: 0;
position: absolute;
left: 0;
top: 100%;
border-right: 50px transparent solid;
border-left: 50px transparent solid;
border-bottom: 0 transparent solid;
border-top: 30px #ffff00 solid;
}
Why not create the full rectangle and then position and overlay triangle images at the bottom that blend with your background to give the look of a down-pointing arrow?
Related
Im creating a website for college and Im not sure how to stop text from overlapping when I make the web browser smaller. This is what I mean:
(not overlapping)
(overlapping)
Here is my jsfiddle: (http://jsfiddle.net/RC4Ar/)
.words {
font-family:apple;
font-size:20px;
max-width:800px;
height:190px;
margin-top:10px;
margin-left:42%;
}
Thanks in advance!
Assuming you are adding the words class to the paragraph tags (without your html, we can only guess), you simply need to remove the height declaration.
.words {
font-family: apple;
font-size: 20px;
max-width: 800px;
margin-top: 10px;
margin-left: 42%; }
For your fiddle example, I would change the title_bar to have a min height instead of a fixed height. This will allow it to be responsive instead of overlapping over the following text.
#title_bar {
margin-top:78px;
left:-17px;
width:101.5%;
min-height:30px;
background:blue;
position:relative;
top:-70px;
z-index:3;
border: 3px rgba(255, 105, 180, 1) solid;
background-image: -webkit-gradient(linear, right bottom, right top, color-stop(0, #5977FF), color-stop(1, #59C5FF));
background-image: -o-linear-gradient(top, #5977FF 0%, #59C5FF 100%);
background-image: -moz-linear-gradient(top, #5977FF 0%, #59C5FF 100%);
background-image: -webkit-linear-gradient(top, #5977FF 0%, #59C5FF 100%);
background-image: -ms-linear-gradient(top, #5977FF 0%, #59C5FF 100%);
background-image: linear-gradient(to top, #5977FF 0%, #59C5FF 100%);
}
Fiddle
Question, if I wanted to create gradient lines that fade out on the top and bottom, similar to the lines seen on AT&T's drop down menu that separate the menu items, how would I go about that? I want to create a similar effect on a menu that I am coding, and I would prefer not to use images. Is there a way to achieve this in CSS? Help much appreciated! Thanks.
Microsoft CSS Gradient is a GUI you can use. just copy the CSS into your code:
Example:
#div {
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(bottom, #FFFFFF 0%, #00A3EF 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(bottom, #FFFFFF 0%, #00A3EF 100%);
/* Opera */
background-image: -o-linear-gradient(bottom, #FFFFFF 0%, #00A3EF 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #FFFFFF), color-stop(1, #00A3EF));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(bottom, #FFFFFF 0%, #00A3EF 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to top, #FFFFFF 0%, #00A3EF 100%);
}
You can create a div with 1px width then assign a gradient on it. Like that :
.line{
width:1px;
height : 25px;
margin : 0 5px;
background: rgb(125,185,232);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzdkYjllOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzFlNTc5OSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3ZGI5ZTgiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(125,185,232,1) 0%, rgba(30,87,153,1) 50%, rgba(125,185,232,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(125,185,232,1)), color-stop(50%,rgba(30,87,153,1)), color-stop(100%,rgba(125,185,232,1)));
background: -webkit-linear-gradient(top, rgba(125,185,232,1) 0%,rgba(30,87,153,1) 50%,rgba(125,185,232,1) 100%);
background: -o-linear-gradient(top, rgba(125,185,232,1) 0%,rgba(30,87,153,1) 50%,rgba(125,185,232,1) 100%);
background: -ms-linear-gradient(top, rgba(125,185,232,1) 0%,rgba(30,87,153,1) 50%,rgba(125,185,232,1) 100%);
background: linear-gradient(to bottom, rgba(125,185,232,1) 0%,rgba(30,87,153,1) 50%,rgba(125,185,232,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7db9e8', endColorstr='#7db9e8',GradientType=0 );
}
Fiddle : http://jsfiddle.net/jPnXz/
Here a CSS gradient generator (i used it for the CSS) : http://www.colorzilla.com/gradient-editor/
Great documentation on CSS3 Gradients
http://www.css3files.com/gradient/
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_gradients
Gradient Generators
http://www.colorzilla.com/gradient-editor/
http://gradients.glrzad.com
http://www.cssmatic.com/gradient-generator
http://ie.microsoft.com/testdrive/graphics/cssgradientbackgroundmaker/
You have repeating-gradient as well for this :
http://codepen.io/anon/pen/zbLkl
background:repeating-linear-gradient(
top ,
white 0,
white 1em,
turquoise 1em,
turquoise 1.2em) 0 2.4em;
line-height:1.2em;
Set equal line-height to gradient , so gradient will follow font-size.
the time to dig it, an old example with squares. and background-size.http://dabblet.com/gist/4750827
background:
linear-gradient(0deg, rgba(0,0,0,0.1) 0 , rgba(0,0,0,0.1) 1px ,transparent 1px ,transparent),
linear-gradient(90deg, rgba(0,0,0,0.1) 0 , rgba(0,0,0,0.1) 1px ,transparent 1px ,transparent);
background-size:1.4em 1.4em,1.4em 1.4em;
line-height:1.4em;
<!DOCTYPE html>
<html>
<head>
<style>
#grad1 {
height: 200px;
background: linear-gradient(to top left ,#FFA500, #DDA0DD,#FFFAF0,#bfff00,#00ffff,#A9A9A9);
}
</style>
</head>
<body>
<h1>Linear Gradient</h1>
<div id="grad1"></div>
<br/>
<div>Internet Explorer 9 and earlier versions do not support gradients</div>
</body>
</html>
I generated gradient background in colorzilla and i put inside css file as u can see in this code and it keeps repeating me the background. I want this background to be from where it starts to the end of page.
body{
background: #1d6fa4;
background: -moz-linear-gradient(-45deg, #1d6fa4 1%, #499bc8 26%, #51abc9 52%, #3e94c1 74%, #277cad 100%);
background: -webkit-gradient(linear, left top, right bottom, color-stop(1%,#1d6fa4), color-stop(26%,#499bc8), color-stop(52%,#51abc9), color-stop(74%,#3e94c1), color-stop(100%,#277cad));
background: -webkit-linear-gradient(-45deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
background: -o-linear-gradient(-45deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
background: -ms-linear-gradient(-45deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
background: linear-gradient(135deg, #1d6fa4 1%,#499bc8 26%,#51abc9 52%,#3e94c1 74%,#277cad 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1d6fa4', endColorstr='#277cad',GradientType=1 );
}
You need this
html, body {
height: 100%;
}
body {
background-position: fixed;
/* Gradient dump goes here */
}
.button_style
{
color:#FFF;
text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
background: #2faa51;
background: -moz-linear-gradient(top, #2faa51 0%, #207337 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #2faa51), color-stop(100%, #207337));
background: -webkit-linear-gradient(top, #2faa51 0%, #207337 100%);
background: -o-linear-gradient(top, #2faa51 0%, #207337 100%);
background: -ms-linear-gradient(top, #2faa51 0%, #207337 100%);
background: linear-gradient(to bottom, #2faa51 0%, #207337 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2faa51', endColorstr='#207337', GradientType=0 );
border:1px solid #178636;
padding:0px 5px;
white-space:nowrap;
font-size:13px !important;
line-height:20px;
font-weight:bold;
-webkit-border-top-left-radius:15px;
-webkit-border-bottom-left-radius:15px;
-webkit-border-bottom-right-radius:15px;
behavior: url(images/ie-css3.htc);
border-radius: 15px 15px 15px 15px;
}
Tried ie-css3 and the above CSS, but can find only round corners carved(outlined) but not rounded edges.Edges are still pointed corners.How to make it a rounded corner button from all four sides.Please help me for this.
No prefix needed for IE:
border-radius: 15px 15px 15px 15px;
With IE9, the important steps are using the edge META tag (in the header):
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
"edge" means "use the latest rendering engine" so IE 9 will use 9, 10 uses 10, etc.
and provide the behavior hack:
behavior: url(images/ie-css3.htc);
I got it to display exactly how I want it in Firefox, but with every other browser there seems to be some problems. This website isn't exactly public (as in, no one knows of it) yet as I'm still trying to get things to display properly, but the URL is: http://www.mixbin.net (just view:source for the code - there's nothing server side interfering)
Firefox: Perfect.
Chrome: Perfect except the bottom margin is being ignored in the .content class.
Opera: Perfect except the bottom margin is being ignored in the .content class.
Safari: Displays gradient properly but forces a refresh as soon as you scroll halfway down the page.
Internet Explorer: Displays gradient properly but .content div is cut off where the gradient stops.
background:linear-gradient(top, #000000 0%, #353535 100%); /*W3C*/
background:-moz-linear-gradient(top, #000000 0%, #353535 100%); /*FF3.6+*/
background:-ms-linear-gradient(top, #000000 0%, #353535 100%); /*IE10+*/
background:-o-linear-gradient(top, #000000 0%, #353535 100%); /*Opera 11.10+*/
background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #353535)); /*Chrome,Safari4+*/
background:-webkit-linear-gradient(top, #000000 0%, #353535 100%); /*Chrome10+,Safari5.1+*/
filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#353535',GradientType=0 ); /*IE6-9*/
No images wanted. So please don't reply with, "just make a background image".
Update 2: Everything (including IE), is now working. I switched these two lines from:
background:-webkit-linear-gradient(top,#000000 0,#353535 100%);
background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#000),color-stop(100%,#353535));
To:
background:-webkit-linear-gradient(top, #000000, #353535);
background:-webkit-gradient(linear, left top, left bottom, from(#000000), to(#353535));
If your CSS for the gradient is:
background: linear-gradient(top, #000000 0%, #353535 512px);
there will be no need for a <div> with height 512px. Unfortunately, this solution works for every browser except IE.
Back to your extra background <div> approach. I copied and modified your code a little. This works for all browsers.
body {
background: #353535;
}
.content {
background-color: white;
height: 1000px;
margin: 20px auto;
width: 300px;
z-index: 2;
position: relative;
}
#background {
position: absolute;
top: 0;
height: 512px;
width: 100%;
background: linear-gradient(top, #000000 0%, #353535 100%); /*W3C*/
background: -moz-linear-gradient(top, #000000 0%, #353535 100%); /*FF3.6+*/
background: -ms-linear-gradient(top, #000000 0%, #353535 100%); /*IE10+*/
background: -o-linear-gradient(top, #000000 0%, #353535 100%); /*Opera 11.10+*/
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #353535)); /*Chrome,Safari4+*/
background: -webkit-linear-gradient(top, #000000 0%, #353535 100%); /*Chrome10+,Safari5.1+*/
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#353535', GradientType=0); /*IE6-9*/
}
<body>
<div id="background"></div>
<div class="content"></div>
</body>
This might not be the solution you are looking for but, since you will have to use hacks to make it looks the same on different browsers, why wont you use an image of the gradient and repeat it in the background.
If your background gradient is 300px, make the image with 300px height and 1px width (image size wont be over 1KB), and repeat it in your background
background: url('bg_gradient.jpg') repeat-x 0px 0px;
It will work on all the browsers without any hassle;