I have a problem with CSS3/SVG button. I don't know how to make linear gradient gradient border like that:
Button
Top button: button has transparent background
Bottom button: button on hover has gradient background (same as on border) with opacity 30%, if it is not possible to do such a gradient background when you hover it can change only the color of border
I have created one demo for you. Though you would have to change the colors it looks almost as you wanted it.
To create the gradient you can use this awesome online tool.
.container{
background:blue;
padding:100px;
float:left;
}
.outsider{
padding:4px 0px 4px 4px;
float:left;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#8887d3+0,cbebff+43,ffffff+100 */
background: rgb(136,135,211); /* Old browsers */
background: -moz-linear-gradient(left, rgba(136,135,211,1) 0%, rgba(203,235,255,1) 43%, rgba(255,255,255,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, rgba(136,135,211,1) 0%,rgba(203,235,255,1) 43%,rgba(255,255,255,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, rgba(136,135,211,1) 0%,rgba(203,235,255,1) 43%,rgba(255,255,255,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8887d3', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
position:relative;
}
.outsider:after{
content: "";
position: absolute;
right: -30px;
width: 0px;
height: 0px;
border-top: 43px solid transparent;
border-bottom: 43px solid transparent;
border-left: 30px solid #FFFFFF;
top: 0px;
}
.outsider:before{
content: "";
position: absolute;
right: -26px;
width: 0px;
height: 0px;
border-top: 39px solid transparent;
border-bottom: 39px solid transparent;
border-left: 26px solid #0000FF;
top: 4px;
z-index: 1;
}
.insider{
padding:30px;
float:left;
color:#FFFFFF;
background:blue;
}
<div class="container">
<div class="outsider">
<div class="insider">
Lorem ipsum dolor silit
</div>
</div>
</div>
I have a form as in the below code ? how can i make it fit to the center of the screen and convert it to be responsive ?
HTML5 Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS3 Search Form</title>
<link href="css/cbdb-search-form.css" type="text/css" rel="stylesheet" media="screen" />
<style type="text/css">
body {
background: #999;
}
</style>
</head>
<body>
<form id="search-form">
<input type="email" />
<input type="submit" value="Login" />
</form>
</body>
</html>
CSS Code
/************************************
CSS 3 SEARCH BY ZEAOS
************************************/
#search-form {
background: #e1e1e1; /* Fallback color for non-css3 browsers */
width: 365px;
/* Gradients */
background: -webkit-gradient( linear,left top, left bottom, color-stop(0, rgb(243,243,243)), color-stop(1, rgb(225,225,225)));
background: -moz-linear-gradient( center top, rgb(243,243,243) 0%, rgb(225,225,225) 100%);
/* Rounded Corners */
border-radius: 17px;
-webkit-border-radius: 17px;
-moz-border-radius: 17px;
/* Shadows */
box-shadow: 1px 1px 2px rgba(0,0,0,.3), 0 0 2px rgba(0,0,0,.3);
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,.3), 0 0 2px rgba(0,0,0,.3);
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,.3), 0 0 2px rgba(0,0,0,.3);
}
/*** TEXT BOX ***/
input[type="email"]{
background: #fafafa; /* Fallback color for non-css3 browsers */
/* Gradients */
background: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(250,250,250)), color-stop(1, rgb(230,230,230)));
background: -moz-linear-gradient( center top, rgb(250,250,250) 0%, rgb(230,230,230) 100%);
border: 0;
border-bottom: 1px solid #fff;
border-right: 1px solid rgba(255,255,255,.8);
font-size: 16px;
margin: 4px;
padding: 5px;
width: 250px;
/* Rounded Corners */
border-radius: 17px;
-webkit-border-radius: 17px;
-moz-border-radius: 17px;
/* Shadows */
box-shadow: -1px -1px 2px rgba(0,0,0,.3), 0 0 1px rgba(0,0,0,.2);
-webkit-box-shadow: -1px -1px 2px rgba(0,0,0,.3), 0 0 1px rgba(0,0,0,.2);
-moz-box-shadow: -1px -1px 2px rgba(0,0,0,.3), 0 0 1px rgba(0,0,0,.2);
}
/*** USER IS FOCUSED ON TEXT BOX ***/
input[type="text"]:focus{
outline: none;
background: #fff; /* Fallback color for non-css3 browsers */
/* Gradients */
background: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(255,255,255)), color-stop(1, rgb(235,235,235)));
background: -moz-linear-gradient( center top, rgb(255,255,255) 0%, rgb(235,235,235) 100%);
}
/*** SEARCH BUTTON ***/
input[type="submit"]{
background: #44921f;/* Fallback color for non-css3 browsers */
/* Gradients */
background: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgb(79,188,32)), color-stop(0.15, rgb(73,157,34)), color-stop(0.88, rgb(62,135,28)), color-stop(1, rgb(49,114,21)));
background: -moz-linear-gradient( center top, rgb(79,188,32) 0%, rgb(73,157,34) 15%, rgb(62,135,28) 88%, rgb(49,114,21) 100%);
border: 0;
color: #eee;
cursor: pointer;
float: right;
font: 16px Arial, Helvetica, sans-serif;
font-weight: bold;
height: 30px;
margin: 4px 4px 0;
text-shadow: 0 -1px 0 rgba(0,0,0,.3);
width: 84px;
outline: none;
/* Rounded Corners */
border-radius: 30px;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
/* Shadows */
box-shadow: -1px -1px 1px rgba(255,255,255,.5), 1px 1px 0 rgba(0,0,0,.4);
-moz-box-shadow: -1px -1px 1px rgba(255,255,255,.5), 1px 1px 0 rgba(0,0,0,.2);
-webkit-box-shadow: -1px -1px 1px rgba(255,255,255,.5), 1px 1px 0 rgba(0,0,0,.4);
}
/*** SEARCH BUTTON HOVER ***/
input[type="submit"]:hover {
background: #4ea923; /* Fallback color for non-css3 browsers */
/* Gradients */
background: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgb(89,222,27)), color-stop(0.15, rgb(83,179,38)), color-stop(0.8, rgb(66,143,27)), color-stop(1, rgb(54,120,22)));
background: -moz-linear-gradient( center top, rgb(89,222,27) 0%, rgb(83,179,38) 15%, rgb(66,143,27) 80%, rgb(54,120,22) 100%);
}
input[type="submit"]:active {
background: #4ea923; /* Fallback color for non-css3 browsers */
/* Gradients */
background: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(89,222,27)),
color-stop(0.15, rgb(83,179,38)), color-stop(0.8, rgb(66,143,27)), color-stop(1, rgb(54,120,22)));
background: -moz-linear-gradient( center bottom, rgb(89,222,27) 0%, rgb(83,179,38) 15%, rgb(66,143,27) 80%, rgb(54,120,22) 100%);
}
EDIT 1
This is a mobile web application . Users consists of both smart phones and oldest devices.
First at all
Remove HTML DOCTYPE or change it to <!DOCTYPE html>. HTML5 is not based on SGML, and therefore does not require a reference to a DTD.
To center Content
Wrap your form in a DIV
<body>
<div class="modal">
<form id="search-form">
<input type="email" />
<input type="submit" value="Login" />
</form>
</div>
</body>
Then Apply this CSS to center on screen.
.modal {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#search-form {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
To be Responsive Use CSS Media Query
Media Queries let you apply styles depending on conditions (screen size, screen type, etc) on the screen where you will see the page.
This is only a simple example. I recommend you read about CSS Media Queries.
In this case you set minimum width and height
#media ( max-width :320px) {
.modal {
min-width: 200px;
min-height: 120px;
}
}
#media ( min-width :321px) {
.modal {
min-width: 300px;
min-height: 220px;
}
}
#media ( min-width :640px) {
.modal {
min-width: 480px;
min-height: 320px;
}
}
#media ( min-width :1200px) {
.modal {
min-width: 700px;
min-height: 400px;
}
}
In the other Hand
Have you thought about using bootstrap?
Enjoy!
First of all for making a responsive form or anything like that always give width in %age followed by giving media queries. You can use bootstrap for making your page even better. you can get bootstrap from getbootstrap.com/. The usage and implementation techniques are mentioned there
To center add position:relative to the body
Then you add these rules to the #form to your css:
#search-form{
margin:auto;
position:absolute;
z-index: 30;
top:0;
bottom:0;
left:0;
right:0;
width: 300px; /*variable*/
height: 300px; /*variable*/
}
To center, add
width: 365px;
height:38px;
position:absolute;
top:50%;
margin-top:-19px;
left:50%;
margin-left:-182px;
in #search-form
for responsive, this could be a starting point:
#media all and (max-width:480px) {
#search-form {
width:100%;
margin-left:-50%;
}
input[type="email"]{
width:70%;
}
input[type="submit"]{
width:20%;
}
}
I've got a simple Bootstrap navbar menu, which works great, but I want to add a little visual indicator to the bottom of the menu div to show which menu item is currently active.
This seems like it should be easy, but particularly notice that the drop shadow needs to move with the indentation - how do we do something like this?
A picture is worth a thousand words, added one below.
EDIT Added Fiddle: http://jsfiddle.net/52VtD/1463/
HTML
<div class="navbar navbar-gradient navbar-static-top">
<div class="container">
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav nav-pills">
<li class="active">
<span class="glyphicon glyphicon-home" />
</li>
<li>
<span class="glyphicon glyphicon-cog" />
</li>
</ul>
</div>
</div>
</div>
CSS
#import url('http://getbootstrap.com/dist/css/bootstrap.css');
/* gradient for main navigation bar */
.navbar-gradient {
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #e5e5e5 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
/* drop shadow */
box-shadow: 3px 3px 3px #888888;
}
Here is a solution with a .png image :
FIDDLE
I added this to you css:
li.active{position:relative;}
li.active::after{
content:"";
background: transparent url("http://i41.tinypic.com/29ofuoh.png") no-repeat center center;
background-size: 15px 17px;
height:17px;
width:100%;
position:absolute;
top:43px;
left:0;
}
You could use something like the following. At least if you don't want to use images and don't mind CSS transforms (Other options may include using an image, drawing the thing with CSS backgrounds or SVG maybe.)
demo
.box{
height: 40px;
width: 200px;
position: relative;
box-shadow: 3px 3px 3px #888;
background: #f4f4f4;
}
.box::after{
display: block;
content: " ";
width: 15px;
height: 15px;
background: #fff;
box-shadow: inset 10px 10px 3px -7px #888;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
bottom: -8px;
right: 50px;
}
Probably needs a little more tweaking but here is a 100% CSS solution.
FIDDLE HERE
#import url('http://getbootstrap.com/dist/css/bootstrap.css');
.triangle {
margin-top:-7px;
width: 0;
height: 0;
margin-left:31px;
}
.triangle::after {
content:'';
border-bottom: 0;
height: 15px;
width: 15px;
background-color: #fff;
position: absolute;
-webkit-transform: rotate(45deg);
z-index: 2;
box-shadow: inset 2px -4px 9px #888;
}
.triangle-cover {
position:absolute;
margin-top:1px;
margin-left:-7px;
z-index:10;
width: 0;
height: 0;
border-bottom: solid 17px white;
border-left: solid 14px transparent;
border-right: solid 14px transparent;
}
and in each li that you want active (and you might have to use a little JS to insert these elements into the DOM of the li is active...)
<li class="active"><img src="http://icons.iconarchive.com/icons/ampeross/qetto-2/48/settings-icon.png" />
<div class="triangle"><span class="triangle-cover"></span></div>
</li>
I have defined a border class in a div:
<div class="border"></div>
.border {
border: 4px solid;
color: #E72665;
}
It gives pink color to the border. But instead of pink only. I can 4 colors in borders each covering 25% how can I do that?
If you mean each side a different color than you can simply break the declaration into specific sides...
border-top: 1px solid red;
border-right: 1px solid blue;
border-bottom: 1px solid green;
border-left: 1px solid yellow;
Per your comment below...
The only other way to achieve what you want would be to utilize the :after pseudo-class to create a separate element that has a background gradient with your 4 colors and to use that as your border.
Here is a demo: http://jsfiddle.net/uLHR6/
.border {
position: relative;
width: 100px;
height: 50px;
background: #ccc;
}
.border:after {
content: " ";
display: block;
position: absolute;
width: 100px;
height: 5px;
bottom: 0;
background: #ff0000; /* Old browsers */
background: -moz-linear-gradient(left, #ff0000 0%, #ff0000 24%, #00ff00 25%, #00ff00 49%, #0008ff 50%, #0008ff 74%, #f605ff 75%, #f605ff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#ff0000), color-stop(24%,#ff0000), color-stop(25%,#00ff00), color-stop(49%,#00ff00), color-stop(50%,#0008ff), color-stop(74%,#0008ff), color-stop(75%,#f605ff), color-stop(100%,#f605ff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #ff0000 0%,#ff0000 24%,#00ff00 25%,#00ff00 49%,#0008ff 50%,#0008ff 74%,#f605ff 75%,#f605ff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #ff0000 0%,#ff0000 24%,#00ff00 25%,#00ff00 49%,#0008ff 50%,#0008ff 74%,#f605ff 75%,#f605ff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #ff0000 0%,#ff0000 24%,#00ff00 25%,#00ff00 49%,#0008ff 50%,#0008ff 74%,#f605ff 75%,#f605ff 100%); /* IE10+ */
background: linear-gradient(to right, #ff0000 0%,#ff0000 24%,#00ff00 25%,#00ff00 49%,#0008ff 50%,#0008ff 74%,#f605ff 75%,#f605ff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff0000', endColorstr='#f605ff',GradientType=1 ); /* IE6-9 */
}
I would like to know if there is any way to change the shape of a bootstrap button, to get something like this:
Any tips?
You won't get that rounded edge on the tip of the nipple of the button unless you use an image and the :after pseudo-element but you can come close to it by using css triangles. Here is short demo i made that uses some color trickery to come close to that effect:
CSS
button.btn {
position:relative;
}
button.btn:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 14px solid transparent;
border-bottom: 14px solid transparent;
border-right: 14px solid #e2e2e2;
position: absolute;
top: 50%;
margin-top: -14px;
right: 98%;
z-index: 2;
}
button.btn:before {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 14px solid transparent;
border-bottom: 14px solid transparent;
border-right: 14px solid #A0A0A0;
position: absolute;
top: 50%;
margin-top: -14px;
right: 97%;
z-index: 1;
}
.btn-primary {
background: #e2e2e2; /* Old browsers */
background: -moz-linear-gradient(left, #e2e2e2 0%, #d1d1d1 47%, #fefefe 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#e2e2e2), color-stop(47%,#d1d1d1), color-stop(100%,#fefefe)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* IE10+ */
background: linear-gradient(left, #e2e2e2 0%,#d1d1d1 47%,#fefefe 100%); /* W3C */
text-shadow: 0 -1px 0 #fff;
color:#777;
border: 1px solid #A0A0A0;
}
I did not include the :hover and :active state styles so you can play around mixing some colors by using the Colorzilla gradient generator.
Here is a demo of what the button looks like:
http://jsfiddle.net/WUn26/