I'm creating a form with gradient borders. To protect against the borders being removed by the browser on autocomplete I've had to wrap all of the elements in a DIV containing their border. box-sizing is used to include the padding in the element size because there's a textarea too. My issue is now with the submit button.
.input-container {
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #006699, #9900CC);
background-origin: border-box;
background-clip: padding-box, border-box;
border: solid 5px transparent;
border-radius: 30px;
margin-bottom: 10px;
overflow: hidden;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
padding: 15px;
display: inline-block;
border: none;
outline: none;
border-radius: 30px;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
font-size: 15px;
background: #FFFFFF;
}
input[type=submit]:hover {
background-image: linear-gradient(-45deg, #006699, #9900CC);
color: #FFFFFF;
}
<div class="input-container">
<input type="submit" name="submit" id="submit" value="Submit" required>
</div>
When a user hovers over the button there's an issue where there's a slight edge. For ease having the border there all of the time makes more sense. Having the border there always means the button only needs to fill rather than having no border and being entirely fill (it causes size to momentarily change)
Any ideas for how to get rid of this small outline on the edges would be appreciated so that the button looks truly filled.
You can see the outline appear occasionally below.
And static here
Is it ok?
.input-container:hover {
border: none;
}
.input-container {
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #006699, #9900CC);
background-origin: border-box;
background-clip: padding-box, border-box;
border-radius: 30px;
margin-bottom: 10px;
overflow: hidden;
border: solid 5px transparent;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
padding: 15px;
display: inline-block;
border: none;
outline: none;
border-radius: 30px;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
font-size: 15px;
background: #FFFFFF;
}
.input-container:hover input[type=submit] {
background-image: linear-gradient(-45deg, #006699, #9900CC);
color: #FFFFFF;
padding:30px 15px;
padding: 20px 15px;
}
<div class="input-container">
<input type="submit" name="submit" id="submit" value="Submit" required>
</div>
As we can see. the border causes this part background-image: linear-gradient(white, white) in .input-container. So lets manipulate it. Added an additional class to parent container .submit-container.
.input-container {
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #006699, #9900CC);
background-origin: border-box;
background-clip: padding-box, border-box;
border: solid 5px transparent;
border-radius: 30px;
margin-bottom: 10px;
overflow: hidden;
box-sizing: border-box;
}
.submit-container:hover {
background-image: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0)), radial-gradient(circle at top right, #006699, #9900CC);
}
input[type=submit] {
width: 100%;
padding: 15px;
display: inline-block;
border: none;
outline: none;
border-radius: 30px;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
font-size: 15px;
background: none;
}
.submit-container:hover input[type=submit] {
color: #FFFFFF;
}
<div class="input-container submit-container">
<input type="submit" name="submit" id="submit" value="Submit" required>
</div>
This white border comes because of padding of outer div. You can do different way like removing div.
input[type=submit] {
width: 100%;
padding: 15px;
display: inline-block;
font-family: 'Roboto', sans-serif;
font-size: 15px;
background-image: linear-gradient(white, white), radial-gradient(circle at top right, #006699, #9900CC);
background-origin: border-box;
background-clip: padding-box, border-box;
border: solid 5px transparent;
border-radius: 30px;
margin-bottom: 10px;
overflow: hidden;
box-sizing: border-box;
}
input[type=submit]:hover {
background-image: linear-gradient(-45deg, #006699, #9900CC);
color: #FFFFFF;
padding: 18px;
border: solid 5px transparent;
}
<input type="submit" name="submit" id="submit" value="Submit" required>
it's because the white linear-gradient on the wrapper background.
below I gave to the gradient the colors of the button and it's look fine now
.input-container {
background-image: linear-gradient(-45deg, #006699, #9900CC), radial-gradient(circle at top right, #006699, #9900CC);
background-origin: border-box;
background-clip: padding-box, border-box;
border: solid 5px transparent;
border-radius: 30px;
margin-bottom: 10px;
overflow: hidden;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
padding: 15px;
display: inline-block;
border: none;
outline: none;
border-radius: 30px;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
font-size: 15px;
background: #FFFFFF;
}
input[type=submit]:hover {
background-image: linear-gradient(-45deg, #006699, #9900CC);
color: #FFFFFF;
}
<div class="input-container">
<input type="submit" name="submit" id="submit" value="Submit" required>
</div>
Related
I was applying a border to this input field along with a gradient:
(https://i.stack.imgur.com/eTqQP.png)
,however because i applied some padding now it is very thick on the left side of the border when i hover the input
Here is the css code:
#input2:hover {
border:2px double transparent;
border-radius: 5px;
background-image: linear-gradient(white,white),
linear-gradient(45deg, #63589A,#5e138d);
background-origin: border-box;
background-clip: content-box,border-box;
cursor: pointer;
}
input {
padding-left: 5px;
border-radius: 5px;
border-color: rgba(237, 237, 237, 255);
}
I want the left- side to look the same as the other border-sides.
Would appreciate it if someone helped me on this!
Use padding-box inside the background-clip instead of content-box
input {
border: 3px solid transparent;
border-radius: 5px;
background-image:
linear-gradient(white, white),
linear-gradient(45deg, #63589A, #5e138d);
background-origin: border-box;
background-clip: padding-box, border-box;
cursor: pointer;
padding: 5px 30px;
font-size: 20px;
outline-offset: 4px;
}
<input type="text" placeholder="some text">
Is this what you were trying to achieve?
#input2 {
padding-left: 5px;
cursor: pointer;
font-family: monospace;
width: 200px;
height: 30px;
}
.input-container {
display: flex;
border-radius: 5px;
width: max-content;
border-color: rgba(237, 237, 237, 255);
padding: 2px;
}
.input-container:hover {
border: none;
background-image: linear-gradient(white, white), linear-gradient(45deg, #63589A, #5e138d);
background-origin: border-box;
background-clip: content-box,border-box;
}
<div class="input-container">
<input id="input2" type="text" placeholder="e.g. 1234 5678 9123 0000"/>
</div>
I am trying to achieve the below design! I have managed to achieve the border radius with gradient border but if i try to use -webkit-background-clip & -webkit-text-fill-color for gradient text then the border radius doesn't work and the whole button gets the gradient color.
I am using this as reference for gradient text and attaching the code for gradient border
.btn {
background-image: linear-gradient(to right, #006175 0%, #00a950 100%);
border-radius: 40px;
box-sizing: border-box;
color: #00a84f;
display: block;
font: 1.125rem 'Oswald', Arial, sans-serif;
/*18*/
height: 80px;
letter-spacing: 1px;
margin: 0 auto;
padding: 4px;
position: relative;
text-decoration: none;
text-transform: uppercase;
width: 264px;
z-index: 2;
}
.btn:hover {
color: #fff;
}
.btn span {
align-items: center;
background: #e7e8e9;
border-radius: 40px;
display: flex;
justify-content: center;
height: 100%;
transition: background .5s ease;
width: 100%;
}
.btn:hover span {
background: transparent;
}
<a class="btn" href="#">
<span>Click Here!</span>
</a>
Any kind of help would be greatly appreciated! Please feel free to give some suggestions. TIA
I will consider this previous answer to build the rounded gradient using pseudo element so that you can use background-clip:text on the main element. I have used the mask version by you can also consider the SVG one:
.btn {
--r:40px; /* radius */
--b:5px; /* border width */
background: linear-gradient(to right, #006175 0%, #00a950 100%);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
color: transparent;
border-radius: var(--r);
display: flex;
align-items: center;
justify-content: center;
font: 1.5rem 'Oswald', Arial, sans-serif;
height: 80px;
margin: 0 auto;
position: relative;
z-index:0;
text-decoration: none;
width: 264px;
}
/* check lined question for the detail of the below code */
.btn::before {
content:"";
position:absolute;
z-index:-1;
inset: 0;
border: var(--b) solid transparent;
border-radius: var(--r);
background: inherit;
background-origin: border-box;
background-clip: border-box;
-webkit-mask:
linear-gradient(#fff 0 0) padding-box,
linear-gradient(#fff 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
-webkit-mask-repeat: no-repeat;
}
/**/
.btn:hover {
color: #fff;
-webkit-text-fill-color: #fff;
-webkit-background-clip: border-box;
background-clip: border-box;
}
.btn:hover::before {
-webkit-mask:none;
}
body {
background:pink;
}
<a class="btn" href="#">
Click Here!
</a>
I got this answer from another post and it worked out for me:
border-bottom: 6px solid transparent;
border-image: linear-gradient(to right, red , yellow);
border-image-slice: 1;
and from my experience, I would use &:after to insert &:hover options to the desired hover effects.
I am trying to add a hover effect which adds background-image when a user hovers on the button but on hover there is a little area left on the left side which is still transparent.
Basically, I added two buttons, next to each other and the problem is with the 2nd button, if I remove first one or move 2nd to next line then it works totally fine.
Here is what am I getting.
Here is how it looks if I remove the first button
Here is the code
.gradient-button-1 {
color: orangered;
background: none;
padding: 1.5rem 3rem;
font-size: 1.3rem;
border: solid 10px transparent;
border-image: linear-gradient(to top right, orangered,yellow);
border-image-slice: 1;
outline: none;
transition: all ease 0.3s;
}
.gradient-button-1:hover {
background-image: linear-gradient(to top right, orangered,yellow);
color: white;
}
.gradient-button-2 {
color: orangered;
background: none;
padding: 1.5rem 3rem;
font-size: 1.3rem;
border: solid 10px transparent;
border-image: linear-gradient(to right, orangered,transparent);
border-image-slice: 1;
outline: none;
transition: all ease 0.3s;
}
.gradient-button-2:hover {
background-image: linear-gradient(to right, orangered,transparent);
border-right: none;
border-right-style: none;
color: white;
}
<section>
<h4>Gradient Bordered Buttons</h4>
<button type="button" name="button" class="gradient-button-1">Gradient button 1</button>
<button type="button" name="button" class="gradient-button-2">Gradient button 2</button>
</section>
In some screen sizes, background is not starting from the left most; which is why it leaves a small gap (white line).
You can add background-origin: border-box; to .gradient-button-2:hover. A good explanation and a live example can be found here at MDN:
The background-origin CSS property sets the background positioning area. In other words, it sets the origin position of an image set with the background-image property.
.gradient-button-1 {
color: orangered;
background: none;
padding: 1.5rem 3rem;
font-size: 1.3rem;
border: solid 10px transparent;
border-image: linear-gradient(to top right, orangered,yellow);
border-image-slice: 1;
outline: none;
transition: all ease 0.3s;
}
.gradient-button-1:hover {
background-image: linear-gradient(to top right, orangered,yellow);
color: white;
}
.gradient-button-2 {
color: orangered;
background: none;
padding: 1.5rem 3rem;
font-size: 1.3rem;
border: solid 10px transparent;
border-image: linear-gradient(to right, orangered,transparent);
border-image-slice: 1;
outline: none;
transition: all ease 0.3s;
}
.gradient-button-2:hover {
background-image: linear-gradient(to right, orangered,transparent);
border-right: none;
border-right-style: none;
color: white;
background-origin: border-box; /* This line is new! */
}
<section>
<h4>Gradient Bordered Buttons</h4>
<button type="button" name="button" class="gradient-button-1">Gradient button 1</button>
<button type="button" name="button" class="gradient-button-2">Gradient button 2</button>
</section>
.gradient-button-1 {
color: orangered;
background: none;
padding: 1.5rem 3rem;
font-size: 1.3rem;
border: solid 10px transparent;
border-image: linear-gradient(to top right, orangered,yellow);
border-image-slice: 1;
outline: none;
transition: all ease 0.3s;
}
.gradient-button-1:hover {
background-image: linear-gradient(to top right, orangered,yellow);
color: white;
background-position: -1px;
background-size: 101%;
}
.gradient-button-2 {
color: orangered;
background: none;
padding: 1.5rem 3rem;
font-size: 1.3rem;
border: solid 10px transparent;
border-image: linear-gradient(to right, orangered,transparent);
border-image-slice: 1;
outline: none;
transition: all ease 0.3s;
}
.gradient-button-2:hover {
background-image: linear-gradient(to right, orangered,transparent);
border-right: none;
border-right-style: none;
color: white;
}
<section>
<h4>Gradient Bordered Buttons</h4>
<button type="button" name="button" class="gradient-button-1">Gradient button 1</button>
<button type="button" name="button" class="gradient-button-2">Gradient button 2</button>
</section>
I tried to get an input field with an submit-button inside it. Instead of using the "normal" submit button, I tried to insert a small icon into the input-field, but without any success. I wasn't able to get the image (dimensions 30*30 pixels) inside my input-field.
<!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
position: relative;
width: 200px;
height: 36px;
box-sizing: border-box;
border: 2px solid #4d7fc3;
border-radius: 4px;
font-size: 16px;
background-color: white;
padding: 2px 2px 2px 10px;
}
input[type=submit] {
position: absolute
width: 30px;
height: 30px;
top: 0px;
right: 0px;
/* background-color: #4d7fc3; */
border: none;
color: white;
background-image: url('file:///C|/Users/heilemann/Pictures/LoginPfeil.JPG');
display: block;
background-position: 100px 100px 100px 100px; */
/* background-repeat: no-repeat; */
/* padding: 2px 2px 2px 30px; */
z-index: -1;
margin: 10px;
cursor: pointer;
}
</style>
</head>
<body>
<p>Input with icon:</p>
<form>
<div id="Search">
<input type="text" name="search" placeholder="Search..">
<input type="submit" value="">
</div>
</form>
</body>
</html>
It should look like this:
There were quite a few errors in the code you pasted up above which weren't doing you any favors.
You left out a ; after the position: absolute; property in your submit input. In order to then have that element positioned properly, you need the parent container to be position: relative;. In this case, the parent container was #Search.
Once that was taken care of there was quite a few properties that could be removed due to being unnecessary. See if my code below helps...
#Search {
position: relative;
display: inline-block;
}
input[type=text] {
position: relative;
width: 200px;
height: 36px;
box-sizing: border-box;
border: 2px solid #4d7fc3;
border-radius: 4px;
font-size: 16px;
background-color: white;
/* 40px padding to account for submit */
padding: 2px 40px 2px 10px;
}
input[type=submit] {
position:absolute;
width: 30px;
height: 100%;
top: 0px;
right: 0px;
border: none;
color: white;
background: url('file:///C|/Users/heilemann/Pictures/LoginPfeil.JPG') #4d7fc3 center center no-repeat;
display: block;
cursor: pointer;
}
Working codepen here.
Just a heads up that your background image for the submit is referencing a local file on your machine, so no one else can actually see it other than you. Be sure to assign it the correct path in relation from the index.html file.
Hope this helps.
Here it is done with HTML and CSS.
/*Clearing Floats*/
.cf:before, .cf:after{
content: "";
display: table;
}
.cf:after{
clear: both;
}
.cf{
zoom: 1;
}
/* Form wrapper styling */
.form-wrapper {
width: 450px;
padding: 15px;
margin: 150px auto 50px auto;
background: #444;
background: rgba(0, 0, 0, .2);
border-radius: 10px;
box-shadow: 0 1px 1px rgba(0, 0, 0, .4) inset, 0 1px 0 rgba(255, 255, 255, .2);
}
/* Form text input */
.form-wrapper input {
width: 330px;
height: 20px;
padding: 10px 5px;
float: left;
font: bold 15px 'lucida sans', 'trebuchet MS', 'Tahoma';
border: 0;
background: #eee;
border-radius: 3px 0 0 3px;
}
.form-wrapper input:focus {
outline: 0;
background: #fff;
box-shadow: 0 0 2px rgba(0, 0, 0, .8) inset;
}
.form-wrapper input::-webkit-input-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
.form-wrapper input:-moz-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
.form-wrapper input:-ms-input-placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
/* Form submit button */
.form-wrapper button {
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 40px;
width: 110px;
font: bold 15px/40px 'lucida sans', 'trebuchet MS', 'Tahoma';
color: #fff;
text-transform: uppercase;
background: #d83c3c;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0, 0, .3);
}
.form-wrapper button:hover{
background: #e54040;
}
.form-wrapper button:active,
.form-wrapper button:focus{
background: #c42f2f;
outline: 0;
}
.form-wrapper button:before { /* Left arrow */
content: '';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent #d83c3c transparent;
top: 12px;
left: -6px;
}
.form-wrapper button:hover:before{
border-right-color: #e54040;
}
.form-wrapper button:focus:before,
.form-wrapper button:active:before{
border-right-color: #c42f2f;
}
.form-wrapper button::-moz-focus-inner { /* Remove extra button spacing for Mozilla Firefox */
border: 0;
padding: 0;
}
<form class="form-wrapper cf">
<input type="text" placeholder="Search..." required>
<button type="submit">Search</button>
</form>
tried both variants, both variants will work, second solution comes clothest
I'm newbie. And I try to make a search box. When I open it on Firefox. It's okay for me. Then I do it in IE, Chrome and Safari. It's not cool actually. Anyone know my problems, please help me fix it?
I want make a search box like this: http://www.behance.net/gallery/Anthracite-EIKON/7171451
<div id="search-box">
<input type="text" name="search" placeholder="Search..."/>
</div>
And CSS:
*{ margin: 0; padding: 0; }
#search-box{
background: -moz-linear-gradient(top right, #353535, #010101);
background: -webkit-linear-gradient(top right, #353535, #010101);
background: -ms-linear-gradient(top right, #353535, #010101);
background: -o-linear-gradient(top right, #353535, #010101);
background: linear-gradient(top right, #353535, #010101);
padding: 30px 0;
position: relative;
}
input {
font-family: Cambria, 'Helvetica Neue',Helvetica,Arial,sans-serif;
font-size: 14px;
font-style: normal;
font-variant: normal;
color: #bebebe;
font-weight: 400;
line-height: 56px;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5) ;
border-radius: 13px;
border: 1px solid #000000;
background-clip: border-box;
padding: 5px 4px 3px 24px;
width: 94px;
height: 27px;
box-shadow: 0 0 9px #121212 inset;
position: absolute;
right: 25px;
top: 15;
background-color: #444444 ;
background-image: url('images/search_icon.png');
background-repeat: no-repeat;
background-size: 12px 12px;
background-position: 9px 8px;
}
input:hover {
box-shadow: none;
}
input:focus {
width: 200px;
box-shadow: none;
text-shadow: none;
color: #4D4E52;
background-color: white ;
background-image: url('images/search_icon5.png');
background-repeat: no-repeat;
background-position: 9px 8px;
}
In your css for input you need to change top:15 to top:15px and change line-height to 24px;
Example: http://jsfiddle.net/justincook/sMG3R/