Two inputs next to each other with box-shadow - css

I'm trying to add a box shadow on two inputs next to each other, but the shadows are overlapping the inputs.
I've tried to add a position: relative and z-index to the inputs, but then the shadow overlap the input with the lowest z-index.
Is there a way to prevent the shadow from overlapping the other input next to it?
HTML:
<form method="post">
<input name="email" type="text" >
<input name="send" type="submit">
</form>
CSS:
.email {
height:45px;
width: 395px;
float: left;
box-shadow: 0 0 40px 6px rgba(0,0,0,0.65);
-webkit-appearance: none;
}
.search {
height: 45px;
width: 60px;
float: right;
box-shadow: 0 0 40px 6px rgba(0,0,0,0.65);
cursor: pointer;
-webkit-appearance: none;
}
Here is an example of what i mean:
Thanks :)
- Jesper

You have to wrap the two inputs into divs :
<form method="post">
<div class="input--email">
<input name="email" type="text" class="email">
</div>
<div class="input--search">
<input name="send" type="submit" class="search">
</div>
</form>
And give them the same shadows :
.input--email, .input--search {
float: left;
box-shadow: 0 0 40px 6px rgba(0,0,0,0.65);
height: 45px;
}
.input--email{
width: 395px;
}
.input--search{
margin-left: 15px;
width: 60px;
}
.email, .search {
width: 100%;
height: 100%;
position: relative;
-webkit-appearance: none;
}
.search {
cursor: pointer;
}
Here is a fiddle : http://jsfiddle.net/VLy6Q/

Related

CSS- Coloured cox inside form field

I am a newbie but pretty good at CSS, But i can not seem to get my head around doing the following:
It is the box and background, that is confusing me. The rest i am perfecting fine with. Any pointers would be very helpful. I know bootstrap have a similar plugin, but i find bootstrap a nightmare to use.
I have tired countless of ridiculous things, i am to embarrassed to show, thought is is about time i ask the pro's.
input[type=text]{
background-color: linear-gradient(90deg, #FFC0CB 50%, #00FFFF 50%);
color: black;
}
input[type=text]{
background-color: red;
color: aqua;
background-size: 20%;
}
HTML
<div id="section_left">
<form id="franchiseDets" action ="Franchise-Details.php" method="POST">
<!-- franchise details form-->
<div class="field">
<input type="text" name="fran_name" id="fran_name" value="<?php echo $_SESSION['fran_name']; ?>" placeholder="e.g One Delivery Leeds" pattern="[a-zA-Z]"
autofocus required tabindex="1">
<br>
<input type="email" name="fran_email" id="fran_email" value="<?php echo $_SESSION['fran_email'] ?> ' <?php echo $disabled ?>" placeholder="leeds#one-delivery.co.uk" required tabindex="2">
<br>
<input type="text" name="mang_name" id="mang_name" value="<?php echo $_SESSION['mang_name']; ?>" placeholder="Joe Blogs" required tabindex="3">
<br>
These are last two ridiculous things i have tired
Here is a method I would usually use.
Pure CSS and semantics :)
HTML
<fieldset class="example">
<input type="text" placeholder="Phone" />
</fieldset>
CSS
fieldset.example {
position: relative;
}
fieldset.example,
fieldset.example:before,
fieldset.example input {
height: 33px;
padding: 0;
border-width: 0;
/* remove default border */
}
fieldset.example input {
border: 1px solid red;
border-left: 0px;
padding-left: 5px;
border-radius: 0 5px 5px 0;
}
fieldset.example:before {
content: "\0260E";
width: 30px;
border: 1px solid red;
display: inline-block;
float: left;
position: relative;
background: red;
color: white;
text-align: center;
line-height: 33px;
border-radius: 5px 0 0 5px;
}
LIVE EXAMPLE
http://codepen.io/KarlDoyle/pen/grRrwG
This is how I would have solved it with less code as comment suggested:
(Do not evauluate the design)
.input-field {
/* And border and so on... */
background-color: #f00;
box-sizing: border-box;
padding-left: 2em;
position: relative;
}
.input-field:before {
content: "X"; /* Use this if the icon comes from a font,
or relpace it with a space and then use the background-image property */
position: absolute;
left: 0;
width: 2em; /* Just to center the padding */
text-align: center;
font-size: 1em; /* For the scalability */
}
.input-field > input {
width: 100%;
font-size: 1em;
}
/* This is just for play, to test the scaleability */
.fill-row {
width: 100%;
}
.big {
font-size: 2em;
}
.short {
max-width: 160px;
}
<div class="input-field fill-row">
<input />
</div>
<div class="input-field big short">
<input />
</div>
<div class="input-field short">
<input />
</div>

How to place background with text over another background image without HTML

I made a form with checkbox as a forest image. I need to place another transparent background with text from html parameter (data-forest) over the forest checbox image but I have to do this only by CSS. I've tried so many solutions but no one work properly. Anyone have some idea?
Final effect on hover:
JsFiddle: https://jsfiddle.net/ac9z8sgd/
HTML
<form action="action" method="get">
<input type="hidden" name="test" value="test" />
<ul>
<li><input id="checkbox" type="checkbox" name="forest_type" value="forest_1"><label for="checkbox_forest" data-forest="Estern forest">Forest 1</label></li>
</ul>
<button type="submit">Submit</button>
</form>
CSS
/* Default check button */
#checkbox + label {
background: url('http://i.imgur.com/Ds7gh7b.jpg?1');
background-repeat: no-repeat;
height: 250px;
width: 250px;
padding: 15px 15px;
display: inline-block;
position: relative;
}
/* Hover action */
#checkbox + label[data-forest]:hover {
background: rgba(0,0,0,0.8);
content: attr(data-forest);
display: inline-block;
font-size: 20px;
color: white;
position: relative;
}
Use a pseudo-element.
/* Default check button */
#checkbox + label {
background: url('http://i.imgur.com/Ds7gh7b.jpg?1');
background-repeat: no-repeat;
height: 275px;
width: 184px;
display: inline-block;
position: relative;
}
/* Hover action */
#checkbox + label[data-forest]:hover::after {
background: rgba(0, 0, 0, 0.8);
content: attr(data-forest);
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50%;
font-size: 20px;
color: white;
display: flex;
}
<form action="action" method="get">
<input type="hidden" name="test" value="test" />
<ul>
<li>
<input id="checkbox" type="checkbox" name="forest_type" value="forest_1">
<label for="checkbox_forest" data-forest="Estern forest">Forest 1</label>
</li>
</ul>
<button type="submit">Submit</button>
</form>
JSfiddle with Transitions
My suggestion:
label[data-forest]:hover:before {
background: rgba(0,0,0,0.8);
content: attr(data-forest);
font-size: 20px;
color: white;
margin-top: 240px;
margin-left: -15px;
position: absolute;
width: 100%;
text-align: center;
}
BTW: Maybe 0.8 is too much a high value for a perceptible transparency. I'd make it 0.4.

Padding for placeholder without changing the size of input

I do adaptive search form. Search field should take 100% width of the parent div (the width of the parent div will change depending on the resolution of the device). The button "Search" should always be at the right of the field, do not shift down.
A working version.
But there's a problem: The text "Search now" (placeholder) too close to the edge of the field and I can't move it to the right. In other examples, it moves by the set value for the field padding. But if I change the padding — field itself is shifted to the left, but I only need to move the text!
#searchfield {
padding: 10px 0 13px 0; /* Try to change the left padding here! All field shifts to the left! But I need only shift the placeholder text to right! */
}
Try adding text-align:center for id searchfield or add box-sizing: border-box; declaration.
try with any one of below examples, it will move the placeholder to right as you expected, these will support Ie lower versions too.
Example1 (using box-sizing:border-box declaration)
#searchfield {
padding: 10px 0 13px 0px;
box-sizing: border-box;
}
Example2 (using text-align:center declaration)
#searchfield {
text-align:center;
}
You can still use padding to move the placeholder text, with the flavor of box-sizing: border-box; declaration.
box-sizing: border-box; make user-agents include padding/border to the width/height of the box.
#searchfield {
width: 100%;
border: 1px solid #ccc;
padding: 10px 0 13px 10px;
box-sizing: border-box;
/* other declarations... */
}
Vendor prefixes omitted due to brevity.
#sidebar {
width: 20%;
background: #ccc;
height: 300px;
padding: 20px;
}
#search {
width: 100%;
height: 50px;
position: relative;}
#searchfield {
width: 100%;
border: 1px solid #ccc;
margin: 0;
padding: 12px 0 13px 10px;
box-sizing: border-box;
position: absolute;
right: 0;
}
#searchsubmit {
width: 60px;
height: 41px;
background: red 0 0;
border: 0;
overflow: hidden;
cursor: pointer;
right: 0;
position: absolute;
}
<html>
<body>
<div id="sidebar">
<div id="search">
<form id="searchform" method="get" action="/index.php" _lpchecked="1">
<input type="text" name="s" id="searchfield" placeholder="Search now">
<input type="submit" id="searchsubmit" value="Search">
</form>
</div>
</div>
</body>
</html>
It's worth mentioning that border-box is supported in IE8+ as well as modern web browsers.
This could do the trick for you. It solved the issue I was having.
Tried on firefox and chrome
.random-class-name{
text-indent: 10px;
}
Text written inside the input is indented as well.
No need to use position absolute. try this code:
<html>
<body>
<div id="sidebar">
<div id="search">
<form id="searchform" method="get" action="/index.php" _lpchecked="1">
<input type="text" name="s" id="searchfield" placeholder="Search now">
<input type="submit" id="searchsubmit" value="Search">
</form>
</div>
</div>
</body>
</html>
#sidebar {
width: 20%;
background: #ccc;
height: 300px;
padding: 20px;
}
#search {
width: 100%;
height: 50px;
position: relative;}
#searchfield {
width: calc(100% - 60px);
border: 1px solid #ccc;
margin: 0;
padding: 10px 0 13px 20px; /* Try to change the left padding here! All field shifts to the left! But I need only shift the placeholder text to right!
position: absolute;*/
right: 0;
float:left;
box-sizing:border-box;
}
#searchsubmit {
width: 60px;
height: 41px;
background: red 0 0;
border: 0;
overflow: hidden;
cursor: pointer;
right: 0;
float:left;
box-sizing:border-box;
}
live demo on code pen

Text disappeared from buttons

I am trying to have it so users can log in into my website using fb etc. For some reason, the text gets hidden behind the buttons in my existing code. I am not sure what's wrong since the text used to show up where it needed to be up until I changed the background of the buttons and added social icons to them. Could you please help?
Here is the relevant code:
HTML:
<a class="alt-sign-in facebook">Login with facebook</a>
<a class="alt-sign-in google">Login with google</a>
<a class="alt-sign-in twitter">Login with twitter</a>
<form>
<input type="text" name="name" placeholder="name">
<input type="text" name="email" placeholder="email">
<input type="submit" name="submit">
</form>
<button id="computer-button">Start</button>
</div>
CSS:
#import url('http://weloveiconfonts.com/api/?family=entypo');
#import url('http://weloveiconfonts.com/api/?family=zocial');
html, body {
height: 100%;
background: #ddd;
}
.alt-sign-in {
position: relative;
display:block;
height: 40px;
width: 300px;
margin: 10px 0px auto auto;
padding: 5px;
font: 700 16px/40px'Quattrocento Sans', sans-serif;
text-decoration: none;
text-transform: uppercase;
text-align:center;
line-height: 40px;
color: #555;
border-radius: 2px;
background: linear-gradient(to bottom, white 40%, lightgrey);
box-shadow: 0 1px 1px rgba(0, 0, 0, .5);
cursor: pointer;
box-sizing: border-box;
}
.alt-sign-in:before {
color:white;
position:relative;
top: -5px;
left: -5px;
display:block;
box-sizing: border-box;
height: 40px;
width: 45px;
font: 20px/40px entypo;
text-align: center;
color: #fff;
border-radius: 2px 0 0 2px;
}
http://jsfiddle.net/prettysweet/Dv9rC/24/
Thank you so much!
The code you have posted seems to be an incomplete, or older version.
But by judging from your jsfiddle link, I suggest to change the following;
.alt-sign-in {
/* removed: box-sizing: border-box; */
}
.alt-sign-in:before {
position:absolute;
top: 5px;
left: 5px;
}
see http://jsfiddle.net/Dv9rC/27/
I think you have floating element problem. If you add these lines to your css code, it'll be OK.
.alt-sign-in.facebook:before {
...
float: left;
}
.alt-sign-in.google:before {
...
float: left;
}
.alt-sign-in.twitter:before {
...
float: left;
}
Bonus Edit: After adding all of these codes, just add form tag to your CSS document for top margin.
form{
margin-top:15px;
}

changing the Style of Radio buttons in jQuery mobile 1.4.0

I have the Following Radio buttons in my jQuery mobile app , I need to style them as the Radio button in the image bellow . I have tried the following css but it didn't give me the same result , Please Help me ..
Html
<div data-role="page">
<div data-role="header" data-theme="b" style="height:63px;">
</div>
<div data-role="content">
<form>
<fieldset>
<input type="radio" id="Male" value=" Male" name="radio-group-1" />
<label for="Male" data-inline="true" style="background:transparent !important;">Male </label>
<input type="radio" id="Female" value=" Female" name="radio-group-1" />
<label for="Female" data-inline="true" style="background:transparent !important;" >Female </label>
</fieldset>
</form>
</div>
</div>
CSS
input[type="radio"] {
display: none;
}
.ui-btn.ui-radio-off:after, .ui-btn.ui-radio-on:after{
width: 25px;
height: 25px;
}
.ui-btn.ui-radio-off:after, .ui-btn.ui-radio-on:after{
margin-top: -18px;
margin-left: -38px;
}
.ui-btn.ui-radio-on:after{
width: 55px;
height: 55px;
background: green !important;
background-size:100px 24px;
}
This is what i get
To get a green inner circle with transparent around it and a border after that, you really need 2 circles. This could be achieved by adding a :before element as well as the :after element in CSS.
Here is a DEMO
The CSS makes the whole button 56px tall and vertically centers the text by making the line-height the same. When off, the radio image is 26x26 with a gray border. When on, the :before css adds a new 26x26 empty circle with a border while the :after css creates a smaller green circle in the center. NOTE: you may need to tweak sizes and margins to get your desired results.
input[type="radio"] {
display: none;
}
.ui-radio label {
height:56px;
line-height: 56px;
padding-left: 50px;
}
.ui-radio .ui-btn.ui-radio-off:after {
background-image: none;
width: 26px;
height: 26px;
border: 2px solid #6E7983;
margin-top: -13px;
}
.ui-radio .ui-btn.ui-radio-on:after {
background-color: #86D51C;
width: 14px;
height: 14px;
margin-top: -6px;
margin-left: 10px;
border: 0;
}
.ui-radio .ui-btn.ui-radio-on:before {
content:"";
position: absolute;
display: block;
border: 2px solid #6E7983;
border-radius: 50%;
background-color: transparent;
width: 26px;
height: 26px;
margin-top: 14px;
margin-left: -39px;
}

Resources