Give some depth to my input - css

I´m trying to do a basic effect in css to give some depth to my input, something like the image below. I´m trying to do with my code below but anything is missing here because my result is not icual to my image example.
My html:
<form>
<input type="text" placeholder="Search..." />
</form>
My css:
input[type="text"] {background-color:#232323; color:#fff; border:1px solid #151515; -webkit-border-radius: 15px;}
What I´m trying:

You will need at last 2 elements here: one for the dark-grey background, the other for the input.
The rest of my answer has been tested and works in IE10 +, FF & Chrome. If you're looking for IE support for 9 and below this wont work out of the box. It also relies on setting some fixed widths.
You'll recall I mentioned two elements, well you should be using a label tag anyway.
Adjust your HTML to te following:
<label>Search
<input type="text" placeholder="Search" />
</label>
The follwoing CSS positions the input to hide label text.
label {
display:inline-block;
border:1px;
padding:10px;
background-color:#111;
position:relative;
color:#FFF;
width:200px;
height:20px;
}
label input {
-moz-box-shadow: inset -1px -1px 2px #CCC;
-webkit-box-shadow: inset -1px -1px 2px #CCC;
box-shadow: inset -1px -1px 2px #CCC;
border-radius:5px;
background-color:#000;
color:#FFF;
border:none;
padding:3px;
position:absolute;
left:5px;
padding:5px;
width:200px;
height:16px;
top:7px; /* This is ((label hight + (padding * 2)) - this height)/2;*/
/* e.g. ((20 + (2 * 10)) - 16)/2 */
}
Demo

Not sure exactly what you mean, but is this getting close to what you want?
input[type="text"] {
background-color:#232323;
color:#fff;
padding:2px 5px;
border:5px solid #151515;
-webkit-border-radius: 15px;
}

Related

Why my buttons and my text box are not well aligned?

I have created a simple html file containing 2 buttons and one text box.
What I don't understand is that the height of my various elements is set equally to 20px for all elements, but they don't seem to be very well aligned (vertically). Even more frustrating, I was expecting my + and - buttons to be center aligned both on the vertical and the horizontal axis.
Do you have any idea what I have missed ?
Many thanks for your kind help.
Contents of 'form.html' :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<title>Form | 24ways.org</title>
<link rel=stylesheet href=style.css>
<script>
</script>
</head>
<body>
<input type="text" name="country" class="resizedTextbox" value="20" readonly>
+
-
</body>
</html>
Contents of 'style.css' :
.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #54a3f7;
-webkit-box-shadow:inset 0px 1px 0px 0px #54a3f7;
box-shadow:inset 0px 1px 0px 0px #54a3f7;
background-color:#3e12cc;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
border:1px solid #0815cc;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:18px;
padding: 0 10px 10px 10px;
text-decoration:none;
text-shadow:0px 1px 0px #154682;
width:20px;
height:20px;
}
.myButton:hover {
background-color:#0061a7;
}
.myButton:active {
position:relative;
top:1px;
}
.resizedTextbox {width: 50px;
height: 20px;
padding: 0 10px 10px 10px;
border-color:#3e12cc;
text-shadow:0px 1px 1px #154682;
background-color:#f5effb;
}
If you want vertical centering on the buttons (which are already using display:inline-block;), you can just use vertical-align. I do this all the time with buttons and icons. Just adjust as needed, i.e. vertical-align:-1px. You can use positive and negative values for vertical-align. You might need your input to have the same display. You could also try adding a margin to the top of the buttons. If that doesn't work, change the buttons to display:block;, use float:left;, and then add margin-top. Haven't tested but this is how I would approach it.
You are not accounting for the 2px top and bottom border on the input field, add 2px to the height of the buttons. https://jsfiddle.net/u8v3rgyt/4/
.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #54a3f7;
-webkit-box-shadow:inset 0px 1px 0px 0px #54a3f7;
box-shadow:inset 0px 1px 0px 0px #54a3f7;
background-color:#3e12cc;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
border:1px solid #0815cc;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:18px;
padding: 0 10px 10px 10px;
text-decoration:none;
text-shadow:0px 1px 0px #154682;
width:20px;
height:22px;
}

Radio Button with rounded shadow on left in Chrome

How do I make the radio button shadow to be rounded in Chrome like how it is displayed in IE? Any help will be appreciated!
IE: (like this)
CHROME: (not like this)
HTML:
<div class="radio"><input type="radio"><label>C#</label></div>
<div class="radio"><input type="radio"><label>Java</label></div>
CSS
input[type="radio"] {
box-shadow: -4px 0 0 maroon;
border-radius: 10px;
}
JS FIDDLE:
http://jsfiddle.net/nikib/b85zpgu5/
You could change the -webkit-appearance property of the input element to get initial or inherit. Then style is according to your need.
input[type="radio"] {
width:15px;
height:15px;
box-shadow: -4px 0 0 maroon;
border-radius: 999px;
-webkit-appearance: inherit;
border:1px solid #999999;
position:relative;
box-sizing:border-box;
}
input[type="radio"]:checked:before {
content:"";
position:absolute;
border-radius: 999px;
left:25%;
top:25%;
width:50%;
height:50%;
background:#999999;
}
Updated Fiddle

How to reduce space between buttons?

I am new to css and html5 and trying to get top buttons to work properly. The buttons are horizontal align left. I can seem to be adding the proper space between them. How can fix my code without messing my page lay out? Thank you very much for your help here is the code:
.dashboard, #logOuta {
width:160px;
padding:10px 25px 12px 26px;
font-size:18px;
text-decoration:none;
font-family:Arial;
color:#fff;
text-align:center;
box-shadow:1px 1px 1px #666;
background:#23A3DA;
background-image:-webkit-linear-gradient(top,#23A3DA,#03171F);
background-image:-moz-linear-gradient(top,#23A3DA,#03171F);
background-image:-ms-linear-gradient(top,#23A3DA,#03171F);
background-image:-o-linear-gradient(top,#23A3DA,#03171F);
background-image:linear-gradient(to bottom,#23A3DA,#03171F);
border-bottom:2px solid #ffd175;
-webkit-border-radius:5;
-moz-border-radius:5;
border-radius:5px;
-webkit-box-shadow:1px 1px 1px #666;
-moz-box-shadow:1px 1px 1px #666;
cursor:pointer
}
.dashboard:hover {
background:#E3A019;
background-image:-webkit-linear-gradient(top,#E3A019,#E3A019);
background-image:-moz-linear-gradient(top,#E3A019,#E3A019);
background-image:-ms-linear-gradient(top,#E3A019,#E3A019);
background-image:-o-linear-gradient(top,#E3A019,#E3A019);
background-image:linear-gradient(to bottom,#E3A019,#E3A019);
text-decoration:none
}
<div class="logoutbox">
<button class="dashboard">Dashboard</button>
<input name="logOuta" type="button" id="logOuta" value="Sign Out"/>
</div>
button {
margin-right: 50px; /* whaever spacing you want */
}

CSS3 rounded corner textbox with style

Im a newbie of css3, although there are a lot of css tool generators outhere, i dont't know how to code this image i provide. Kindly help please??..This will benefit my assignment on one of my major subject. Thanks a lot!
it's very simple in CSS to round the corners of a div use 'border-radius' CSS property on the div tag and place the image within it.
Your HTML will look like this:
<div id=image_box>
<img src='someimagelocation'>
</div>
You will then want to set the size of the dive to the exact width and height of the image and ensure that overflow is set to hidden and that your border radius property is set:
#image_box {
width:200px;
height:150px;
overflow: hidden;
border-radius:0.5em;
}
this should give you your desired result!
ADDED:
To add dropshadow etc, use the CSS property 'box-shadow' in the same div CSS tag.
box-shadow:0 1px 2px #aaa;
You will need to google how these syntax work. But I have given you all the necessary tools to research it very easily
The trick is to use box-shadow multiple times:
box-shadow: 0 4px 6px -5px hsl(0, 0%, 40%), inset 0px 4px 6px -5px black;
Demo: http://jsfiddle.net/wUgXk/1/
If you're on Google Chrome, open up Inspector, click on one of the values (4px, for instance) and press your Up and Down keys. You can tweak the values in real time and setup these kinds of effects pretty quickly.
Try this
<html>
<html>
<head>
<style type="text/css">
.tbox
{
border:2px solid #b3b3b3;
background:#dddddd;
width:200px;
border-radius:25px;
-moz-border-radius:25px;
-moz-box-shadow: 1px 1px 1px #ccc;
-webkit-box-shadow: 1px 1px 1px 1px #ccc;
box-shadow: 1px 2px 2px 2px #ccc;
}
</style>
</head>
<body>
<input type="text" class="tbox" />
</body>
</html>
<input type="text" placeholder="Your Name" style="text-align:center; color:white; background:black; border-radius:50px; height:30;" />
<input type="email" placeholder="Enter your email id" style="text-align:center; color:white; background:black; border-radius:50px 5px 50px; height:30;" />
Seccond textbox in Different style

CSS alignment in IE

Hi i created a label with some css. The label css is working fine Firefox , chrome but when i run in IE the css is not coming properly.
label.formInputField {width:119px; height:26px; margin:3px 0px 0 0; padding:11px 6px 0 6px; background: #dadada url('css-images/labelBG.png') 50% 50% repeat-x; float:left; display: block; font-size: 12px; font-weight: normal; line-height: 1.1; color:#333; text-align:right; border: 1px solid #AAAAAA; border-right: 1px solid #dadada; }
.div_form_textbox { width:200px; float:left; text-align:left; background-color:#E6E6E6; height:29px; margin:3px 2px 0 0; padding:5px 0 3px 5px; border-right: 1px solid #AAAAAA;border-top: 1px solid #AAAAAA;border-bottom: 1px solid #AAAAAA; background: #e6e6e6 url('siva_images/form_input_bg.png') 50% 50% repeat-x;}
.ui-corner-left { -webkit-border-bottom-left-radius :4px;-webkit-border-top-left-radius :4px; border-bottom-left-radius: 4px; border-top-left-radius: 4px; }
.ui-corner-right { -webkit-border-bottom-right-radius :4px;-webkit-border-top-right-radius :4px;border-bottom-right-radius: 4px; border-top-right-radius: 4px; }
<label class ="formInputField ui-corner-left" for="Pdoctor">Doctor First Name:</label>
<div class="div_form_textbox ui-corner-right">
<input id="fname" name="fname" type="text" size="30" class="textbox ui-corner-all"/>
</div>
The proper output in mozilla and chrome like this
So the same thing in IE is coming like this:
The left side is the label and the right is the div inside there is a textbox. my problem
Only half of that is coming in the label of doctors first name . Please help me to get out this issue
I get that exact behaviour in IE when I look at it in Quirks Mode.
You probably just need to add a valid doctype as the very first line, such as:
<!DOCTYPE html>
If you already have that, then there are other possible reasons for Quirks Mode.
IE8 and less browsers cannot render CSS3 -webkit commands. Like the one you have used in css style:
.ui-corner-left { -webkit-border-bottom-left-radius :4px;....

Resources