I have truble setting input width to 100% in my search form.
I'm not sure what I'm doing wrong. Tried setting 100% everywhere posible, put it's only changes when I set size px.
http://jsfiddle.net/26Gmz/
.searchInput {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #CCCCCC;
border-radius: 5px;
display: table-cell;
height: 29px;
padding: 0 4px;
vertical-align: middle;
width: 100%;
}
.searchIn {
-moz-appearance: none;
-moz-box-sizing: border-box;
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border: 0 none;
font-size: 15px;
margin: 0;
outline-width: 0;
padding-left: 4px;
width: 97%;
}
<form method="post">
<div class="searchEn">
<input type=hidden name="do" value=search>
<input type="hidden" name="subaction" value="search" />
<div class="searchInput">
<input class="searchIn" name="story" width="100%" type="text" />
</div>
</div>
</form>
I think you can get the effect you are after by changing the display rule of .searchInput to block (and then the width to 98%) like this (demo)
.searchInput {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #CCCCCC;
border-radius: 5px;
display: block;
height: 29px;
padding: 0 4px;
vertical-align: middle;
width: 98%;
}
Or for a more complete fix (addressing a bunch of padding and width issues) you could use this CSS (demo) (changes are commented)
.searchEn {
background-image: linear-gradient(to bottom, #FFFFFF 0px, #DFDFDF 100%);
border-radius: 5px;
color: #000000;
/*Push the right side over slightly more*/
padding: 4px 6px 4px 4px;
}
.searchInput {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #CCCCCC;
border-radius: 5px;
display: block;
height: 29px;
/*Remove padding from this element (now in the parent element)*/
padding: 0;
vertical-align: middle;
/*These can be full width if you fix the padding on the parent element*/
width: 100%;
}
.searchIn {
-moz-appearance: none;
-moz-box-sizing: border-box;
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border: 0 none;
font-size: 15px;
margin: 0;
outline-width: 0;
padding-left: 4px;
/*Center the input box better inside the container*/
padding-top: 6px;
/*And make the input full width*/
width: 100%;
}
Related
I want to style the input box so I have created an outside div element that contains my input element. When I click on the input element to write inside of it the border for it shows which I don't want since it ruins the look for the element I have created.
How do I make it so that the border for the input element is hidden when I click on the input element?
.loginbox {
width: 300px;
height: 260px;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 2px 4px rgb(0 0 0 / 10%), 0 8px 16px rgb(0 0 0 / 10%);
box-sizing: border-box;
padding: 10px;
}
.input-text {
width: 95%;
height: 95%;
border: none;
font-size: 90%;
display: block;
}
.input-text::placeholder {
color: #b7b7b7;
font-family: SFProDisplay-Regular, Helvetica, Arial, sans-serif;
}
.input-text-border {
border: 1px solid #afafaf;
padding: 5px;
width: 90%;
height: 10%;
background-color: #ffffff;
border-radius: 6px;
}
<div class="loginbox">
<div class="input-text-border">
<input type="text" class="input-text" placeholder="Email or phone number">
</div>
</div>
It is a browser default and an accessibility feature. Make sure you add something visually equivalent to make it clear for the user.
You can use :focus and :focus-within to target this behavior. This "border" is an outline so you can override it.
.loginbox {
width: 300px;
height: 260px;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 2px 4px rgb(0 0 0 / 10%), 0 8px 16px rgb(0 0 0 / 10%);
box-sizing: border-box;
padding: 10px;
}
.input-text {
width: 95%;
height: 95%;
border: none;
font-size: 90%;
display: block;
}
.input-text:focus {
outline: none;
}
.input-text::placeholder {
color: #b7b7b7;
font-family: SFProDisplay-Regular, Helvetica, Arial, sans-serif;
}
.input-text-border {
border: 1px solid #afafaf;
padding: 5px;
width: 90%;
height: 10%;
background-color: #ffffff;
border-radius: 6px;
}
<div class="loginbox">
<div class="input-text-border">
<input type="text" class="input-text" placeholder="Email or phone number">
</div>
</div>
you can use outline to style outline of any input tags.
input:focus {
outline: 1px solid tomato;
}
We need to use the HTML type for hiding the input field. Using this attribute, the input field will no longer be visible on the page.
By this tag we can hide input field in the page .
Is there anyway to stop the background-image jumping when the input has focus.
A 2px border is added to the input when it gets focus but this causes the image to jump.
Adding background-attachment: fixed causes the image to disappear.
.search_box {
border: 1px solid #0065bd;
background-color: #fff;
background: url("http://png-5.findicons.com/files/icons/980/yuuminco/256/search.png");
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: left;
padding-right: 20px !important;
padding-top: 2px !important;
padding-bottom: 2px !important;
padding-left: 5px !important;
height: 42px;
width: 100%;
padding: 6px 12px;
}
.search_box:focus {
background-color: #d9effc;
border: 2px solid #0065bd;
}
<input type="text" class="textbox search_box" name="keywords" />
first, define the background position for both dimension. I strongly recommend to do this in pixels. Then, on the focus-style, reset the background-position to -1px -1px to compensate the new extra border pixel.
.search_box {
[...]
background-position: 0 0;
}
.search_box:focus {
[...]
background-position: -1px -1px;
}
You can use box-sizing: border-box; on .search_box to make it stay the same size even with a bigger border, and margin-left: -1px;
on .search_box:focus to keep it in the same place.
.search_box {
border: 1px solid #0065bd;
background-color: #fff;
background: url("http://png-5.findicons.com/files/icons/980/yuuminco/256/search.png");
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: left;
padding-right: 20px !important;
padding-top: 2px !important;
padding-bottom: 2px !important;
padding-left: 5px !important;
height: 42px;
width: 100%;
padding: 6px 12px;
box-sizing: border-box;
}
.search_box:focus {
background-color: #d9effc;
border: 2px solid #0065bd;
margin-left: -1px;
}
<input type="text" class="textbox search_box" name="keywords" />
Use box-shadow.
I usually generate mine with this generator: Box Shadow Generator
.search_box {
border: 1px solid #0065bd;
background-color: #fff;
background: url("http://png-5.findicons.com/files/icons/980/yuuminco/256/search.png");
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: left;
padding-right: 20px !important;
padding-top: 2px !important;
padding-bottom: 2px !important;
padding-left: 5px !important;
height: 42px;
width: 100%;
padding: 6px 12px;
}
.search_box:focus {
background-color: #d9effc;
box-shadow: 0px 0px 0px 2px rgba(0,101,189,1);
}
<input type="text" class="textbox search_box" name="keywords" />
I'm trying to create an input form and the right side of my input boxes keep getting cut off. My code is as follows:
HTML/CSS
.add_idea_box {
background-color: #ffffff;
min-width: 1110px;
margin: 0px 20px 20px 20px;
overflow: hidden;
border: solid 1px #6a6a6a;
box-shadow: 3px 3px 3px #cecdcd;
-moz-box-shadow: 3px 3px 3px #cecdcd;
-webkit-box-shadow: 3px 3px 3px #cecdcd;
text-align: center;
padding-right: 25px;
}
.add_idea_box_left {
float: left;
overflow: hidden;
width: 130px;
height: 200px;
}
.add_idea_box_left_top {
width: 100%;
padding: 15px 20px 20px 0px;
}
.add_idea_box_left_bottom {
width: 100%;
text-align: left;
padding-left: 22px;
}
.add_idea_box_left_bottom_row {
width: 100%;
height: 27px;
font-family: "Arial";
font-size: 85%;
color: #363636;
}
.red_circle {
display: inline;
float: left;
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #ff5f57;
margin-right: 7px;
}
.yellow_circle {
display: inline;
float: left;
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #ffbd2e;
margin-right: 7px;
}
.green_circle {
display: inline;
float: left;
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #29cb41;
margin-right: 7px;
}
.add_idea_box_right {
overflow: hidden;
text-align: left;
min-height: 200px;
padding: 20px 0px 0px 25px;
border-left: solid 1px #bab6b6;
}
.add_idea_box_right_top {
overflow: visible;
width: 100%;
}
.add_idea_box_right_bottom {
overflow: hidden;
float: right;
height: 40px;
margin-top: 10px;
margin-bottom: 10px;
}
input[type=submit] {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #ffffff;
padding: 10px 10px;
background: -moz-linear-gradient(
top,
#fa8e00 0%,
#ab0000);
background: -webkit-gradient(
linear, left top, left bottom,
from(#fa8e00),
to(#ab0000));
border: 1px solid #7d0000;
-moz-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 2px rgba(255,255,255,0.7);
-webkit-box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 2px rgba(255,255,255,0.7);
box-shadow:
0px 1px 3px rgba(000,000,000,0.5),
inset 0px 0px 2px rgba(255,255,255,0.7);
text-shadow:
0px -1px 0px rgba(000,000,000,0.4),
0px 1px 0px rgba(255,255,255,0.3);
}
input[type=text] {
width: 100%;
height: 20px;
padding: 10px 10px;
border: 1px solid #bab6b6;
-webkit-border-radius: 6px;
border-radius: 6px;
font-family: "Arial";
color: #bab6b6;
background: #efeeee;
}
textarea {
width: 100%;
height: 60px;
padding: 10px 10px;
border: 1px solid #bab6b6;
-webkit-border-radius: 6px;
border-radius: 6px;
margin-top: 10px;
font-family: "Arial";
color: #bab6b6;
background: #efeeee;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="application/xml; charset=utf-8">
<meta name="viewport" content="initial-scale=1">
<html lang="en">
<head>
<title>GroupTrades</title>
<!-- CSS -->
<link type="text/css" href="css/ideaboard2.css" rel="stylesheet" media="screen">
</head>
<body>
<!-- ADD AN IDEA BOX -->
<div class="add_idea_box">
<div class="add_idea_box_left">
<div class="add_idea_box_left_top">
</div>
<div class="add_idea_box_left_bottom">
<div class="add_idea_box_left_bottom_row">
<div class="green_circle"></div>5 accepted
</div>
<div class="add_idea_box_left_bottom_row">
<div class="yellow_circle"></div>2 pending
</div>
<div class="add_idea_box_left_bottom_row">
<div class="red_circle"></div>3 rejected
</div>
</div>
</div>
<div class="add_idea_box_right">
<form method="post" action="dashboard.php">
<div class="add_idea_box_right_top">
<input type="hidden" name="group" value="<?echo $group;?>">
<input type="text" name="title" value="Title" autofocus>
<textarea value="idea" id="idea">Idea</textarea>
</div>
<div class="add_idea_box_right_bottom">
<input type="submit" id="Submit" name="Submit" value="Add Idea">
</div>
</form>
</div>
</div>
<br><br><br>
</body>
A live version is at: http://quickid.net/test2/ideaboard2.html ... You can see that the right side of the input box and the text box are both getting cut off and their right borders are not showing.
Any help would be greatly appreciated. Thanks!
Add box-sizing property to input and text-area and style accordingly
CSS
.add_idea_box_right_top input[type="text"],
.add_idea_box_right_top textarea{
box-sizing:border-box;
}
hope this helps..
It's because you have set all of these properties on your input element:
width: 100%
padding: 10px
border: 2px
So the input element takes up 100% of the width and it also has 10px padding both left and right on top of that and 2px border on top of that. They all add up so the total width of your element is more than 100% of the width of the containing element.
Try modifying the padding of this class, so try this one.
FROM THIS:
.add_idea_box_right {
overflow: hidden;
text-align: left;
min-height: 200px;
padding: 20px 0px 0px 25px;
border-left: solid 1px #bab6b6;
}
TO THIS:
.add_idea_box_right {
overflow: hidden;
text-align: left;
min-height: 200px;
padding: 20px 25px 0px 25px;
border-left: solid 1px #bab6b6;
}
Let me know if it helped you.
It is because 100% width as suggested is interfering with some of the padding, reduce the width to a smaller percentage and center your input field for it to scale better with increasing resolutions.
Edit: If you inspect element on mozilla you can clearly see where the overlap happens with the pick element thing!
My target output want same as like blow image.
My CSS and HTML:
header {
height: 40px;
width: 100%;
position: fixed;
background: #00A6E3;
top: 0;
left: 0;
border-radius: 0 0 10px 10px;
padding: 15px;
box-shadow: 0 2px 5px rgba(44, 62, 88, 0.15);
display: block;
z-index: 5;
}
header .todoitem {
width: 100%;
height: 100%;
float: left;
border: none;
border-radius: 5px;
background: rgba(255, 255, 255, 0.2);
text-indent: 20px;
}
header input::-webkit-input-placeholder {
color: #fff;
}
<header>
<input type="text" name="todoitem" class="todoitem" placeholder="Enter your activity...">
</header>
After write my code input left side showing properly but the right side not showing properly. From my knowledge right side need show 15px padding. But I can't understand what wrong with my code.
Two possible solutions:
First, you could add box-sizing: border-box to your styles. As it is, your header is set to match the entire width of its container, and then the padding is applied outside that, which is the default behaviour for box-sizing, and which makes the padding extend outside the limits of the container.
Some more reading on css-tricks.com.
You also need to adjust the height to allow for the new box model (total height now includes the height of the padding) - here's your updated code:
header {
box-sizing: border-box;
height: 70px;
width: 100%;
position: fixed;
background: #00A6E3;
top: 0;
left: 0;
border-radius: 0 0 10px 10px;
padding: 15px;
box-shadow: 0 2px 5px rgba(44, 62, 88, 0.15);
display: block;
z-index: 5;
}
header .todoitem {
width: 100%;
height: 100%;
float: left;
border: none;
border-radius: 5px;
background: rgba(255, 255, 255, 0.2);
text-indent: 20px;
}
header input::-webkit-input-placeholder {
color: #fff;
}
<header>
<input type="text" name="todoitem" class="todoitem" placeholder="Enter your activity...">
</header>
Option 2: if you prefer to keep the default box model, you can use a calculated width to compensate for the padding: set the width of header to calc(100% - 30px) (be careful to keep the spaces around the - if you choose this option).
This solution is for you.
body{
margin:0;
padding:0;
}
header{
height: 40px;
display:block;
background: #00A6E3;
border-radius: 0 0 10px 10px;
padding:15px 15px 15px 15px;
box-shadow: 0 2px 5px rgba(44, 62, 88, 0.15);
z-index: 5;
}
header .todoitem{
height: 100%;
width:100%;
display:block;
border: none;
border-radius: 5px;
background: rgba(255, 255, 255, 0.2);
text-indent: 20px;
}
header input::-webkit-input-placeholder{
color: #fff;
}
<header>
<input type="text" name="todoitem" class="todoitem" placeholder="Enter your activity...">
</header>
You can do something like this, too.
header {
height: 70px;
width: 100%;
position:fixed;
background: #00A6E3;
top: 0;
left: 0;
border-radius: 0 0 10px 10px;
padding: 15px;
box-sizing:border-box;
}
header .todoitem {
width: 100%;
height: 100%;
float: left;
border: none;
border-radius: 5px;
background: rgba(255, 255, 255, 0.2);
text-indent: 20px;
}
header input::-webkit-input-placeholder {
color: #fff;
}
<header>
<input type="text" name="todoitem" class="todoitem" placeholder="Enter your activity...">
</header>
I have used box-sizing:border-box so padding is included in total width, and increased height of header, accordingly... Main problem was that your padding actually increased width of header - so header width was over 100% (100% + padding).
More about box-sizing: https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing
header {
height: 40px;
background: #00A6E3;
top: 0;
left: 0;
border-radius: 0 0 10px 10px;
padding: 15px;
box-shadow: 0 2px 5px rgba(44, 62, 88, 0.15);
display: block;
z-index: 5;
}
header .todoitem {
width: 100%;
height: 100%;
float: left;
border: none;
border-radius: 5px;
background: rgba(255, 255, 255, 0.2);
text-indent: 20px;
}
header input::-webkit-input-placeholder {
color: #fff;
}
<header>
<input type="text" name="todoitem" class="todoitem" placeholder="Enter your activity...">
</header>
header {
height: 40px;
width: 100%;
position: fixed;
background: #00A6E3;
top: 0;
left: 0;
border-radius: 0 0 10px 10px;
padding: 15px;
box-shadow: 0 2px 5px rgba(44, 62, 88, 0.15);
display: block;
z-index: 5;
}
header .todoitem {
width: 100%;
height: 100%;
float: left;
border: none;
border-radius: 5px;
background: rgba(255, 255, 255, 0.2);
text-indent: 20px;
}
header input::-webkit-input-placeholder {
color: #fff;
}
<header>
<input type="text" name="todoitem" class="todoitem" placeholder="Enter your activity...">
</header>
Try removing float:left, and add text-align:center to header, and text-align:left to .todoitem, then add margin values to .todoitem to position it where you want.
Width:100% and padding:2px;
doesn't goes well, It never does. Either reduce width to 98% or add padding as padding :15px 0;
header {
height: 40px;
width: 100%;
position: fixed;
background: #00A6E3;
top: 0;
left: 0;
border-radius: 0 0 10px 10px;
padding: 15px 0;
box-shadow: 0 2px 5px rgba(44, 62, 88, 0.15);
display: block;
z-index: 5;
}
I am trying to stylise a menu using CSS and I am having an issue with the text-shadow effect clipping inside the dropdown. The text itself seems to be clipping inside the select borders, which is surprising because I would have thought that it would be allowed to spread into the padded area.
html,
body {
font-family: Calibri;
margin: 0px;
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
cursor: default;
}
#dropdown_user_select{
position: absolute;
left: 25px;
top: 25px;
}
select {
background: none;
border: 1px solid;
border-radius: 2px;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555 inset;
text-shadow: 0px 0px 10px #555;
text-align: center;
transition: 0.4s all ease-out;
font-size: 25px;
padding: 10px 10px 10px 30px;
cursor: auto;
-webkit-appearance: none;
background: #DDD;
overflow: visible;
}
.cutoff {
overflow: visible;
}
#arrow_down {
/* a customised arrow on the left of the dropdown */
border-width: 15px 10px 0px 10px;
border-color: #000 transparent transparent transparent;
position: absolute;
left: 30px;
top: 45px;
}
<div class="cutoff">
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
</div>
<div id="arrow_down" class="arrow_pointer"></div>
as you can see, I have tried to use a div with the overflow: visible to fix this but it has not worked.
EDIT
By clipping, I mean the text-shadow is cut off inside of the tag. Here is an example that shows this better than the above:
html,
body {
font-family: Calibri;
margin: 0px;
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
}
#dropdown_user_select{
position: absolute;
left: 25px;
top: 25px;
}
select {
border: 1px solid;
border-radius: 2px;
text-shadow: 0px 0px 10px #F00;
font-size: 25px;
padding: 10px 10px 10px 30px;
-webkit-appearance: none;
background: #FFF;
overflow: visible;
}
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
The issue is probably that the <option> tag cannot have a padding itself, and the one set on the select actually pushes the left edge of the options, cutting off the shadow.
By using some trickery it seems to work on Chrome, it's not tested on other browsers although I assume it's fine.
The text-indent fixes the left shadow, while the line-height fixes the vertical shadows.
select {
border: 1px solid;
border-radius: 2px;
text-shadow: 0px 0px 20px #F00; /* increased to test vertical cut */
text-indent: 20px; /* fix the left shadow */
line-height: 40px; /* fix the top/bottom shadows */
font-size: 25px;
padding: 10px 10px 10px 0; /* removed left padding to compensate with indent */
-webkit-appearance: none;
background: #FFF;
overflow: visible;
}
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
It is hard to figure out what exactly you're trying to accomplish, but if I read correctly, the text inside is clipping outside of the borders for you. Also, I wasn't sure what you meant by the shadows... here's a JSfiddle:
html, body {
font-family: Calibri;
margin: 0px;
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
cursor: default;
}
#dropdown_user_select{
position: absolute;
left: 25px;
top: 25px;
}
select {
background: none;
border: 1px solid;
border-radius: 2px;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555;
text-shadow: 0px 0px 10px #555;
text-align: center;
transition: 0.4s all ease-out;
font-size: 25px;
padding: 10px 15px 10px 25px;
cursor: auto;
-webkit-appearance: none;
background: #DDD;
overflow: visible;
}
.cutoff {
overflow: hidden;
}
#arrow_down {
/* a customised arrow on the left of the dropdown */
border-width: 15px 10px 0px 10px;
border-color: #000 transparent transparent transparent;
position: absolute;
left: 30px;
top: 45px;
}
<div class="cutoff">
<select id="dropdown_user_select">
<option value="ADMIN">ADMIN</option>
<option value="username">username</option>
</select>
</div>
<div id="arrow_down" class="arrow_pointer"></div>
I edited the overflow value in .cutoff and took away inset from your box shadow in select. I also edited your padding values to accommodate for the width of the down arrow. Not sure if that was what was happening, but I hope I helped.
If it's not what happened, please explain to me what did happen so I can try to help.