I need to display the input field and i need give border bottom , left and right. But here i want only small portion border left side and right side.
.solid {
border-style: solid;
border-left-style: dashed;
border-top: none;
border-right-style: dashed;
}
<input class="solid">
You can use box-shadow to create this type of border.
input {
width: 300px;
border: none;
margin: 50px;
height: 35px;
box-shadow: 13px 13px 0px -10px #000000, -13px 13px 0px -10px #000000;
outline: none;
font-size: 22px;
background: none;
}
<input type="text">
Here you go. I had to add a div element outside the input field to use the before and after selectors.
.field {
position: relative;
display: inline-block;
}
.solid {
border: none;
border-bottom: 2px solid #000;
padding: 5px;
}
.solid:focus {
outline: none;
}
.field::after {
content: '';
width: 2px;
height: 10px;
position: absolute;
background: #000;
bottom: 0;
right: 0;
}
.field::before {
content: '';
width: 2px;
height: 10px;
position: absolute;
background: #000;
bottom: 0;
left: 0;
z-index: 1;
}
<div class="field">
<input class="solid" type="text">
</div>
Here is how you can give input border left and right of small length
Html
<input type="text">
CSS
input[type="text"] {
padding: 20px;
background: linear-gradient(#000, #000), linear-gradient(#000, #000),linear-gradient(#000, #000);
background-size: 1px 20%, 100% 1px, 1px 20%;
background-position: bottom left, bottom center, bottom right;
background-repeat: no-repeat;
border: none;
color: #999;
}
Find the working fiddle
Reference
html,body,input {
padding: 0;
margin: 0;
border: 0;
background-color: transparent;
}
.input-block {
position: relative;
width: 216px;/* important to define input width;width of input + 2x padding*/
margin: 0 auto;
}
input {
width: 208px;
padding: 0 4px;
outline: none;
border-bottom: 1px solid black;
}
.input-lr-border {
position: absolute;
width: 1px;
background-color: black;
bottom: 0;
height: 4px;
}
.left-border-input {
left: 0;
}
.right-border-input {
right: 0;
}
<div class="input-block">
<div class="left-border-input input-lr-border"></div>
<input/>
<div class="right-border-input input-lr-border"></div>
</div>
li{
list-style: none;
width: 200px;
border-bottom: 2px solid #000;
position: relative;
padding: 2px 5px;
margin: 0 0 10px;
}
li:before, li:after{
background: #000;
content: '';
position: absolute;
bottom: 0;
width: 2px;
height: 5px;
}
li:before{
left: 0;
}
li:after{
right: 0;
}
input{
border:0;
outline: none;
}
<ul>
<li><input type="text" placeholder="First Name" /></li>
<li><input type="text" placeholder="Last Name" /></li>
<li><input type="text" placeholder="Email" /></li>
</ul>
Related
I created a form submit on html/css... pls check it out in this link below
https://codepen.io/letsimoo/pen/PobxGRG
HTML Code
<form action="">
<div class="container">
<input class="required-input" type="text" id="name" required />
<label class="required-label" for="name">Name:</label>
</div>
<div class="container">
<input class="required-input" type="text" id="email" required />
<label class="required-label" for="email">Email:</label>
</div>
<div class="container" >
<input class="not-required-input" type="text" id="budget"/>
<label class="not-required-label" for="budget">Budget:</label>
</div>
<div class="container">
<input class="required-input" type="text" id="Message" required style="height: 100px"/>
<label class="required-label" for="Message">Message:</label>
</div>
<input type="submit" value="Submit">
</form>
CSS Code
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600);
* {
box-sizing: border-box;
}
/*Just to center the Form*/
form {
height: 100%;
width: 400px;
overflow: auto;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
/* A container to position LABELS */
.container {
position: relative;
/* top: auto;
left: auto;
width: auto; */
}
.required-input {
padding: 1em;
border: 1px solid #ccc;
-webkit-box-shadow: inset 0 1px 0 #eee, #fff 0 1px 0;
box-shadow: inset 0 1px 0 #eee, #fff 0 1px 0;
border-radius: 5px;
width: 100%;
background-color: black;
color: lightgray;
}
/* I put label on top of the input*/
.required-label {
position: absolute;
top: 0;
right: 1px;
bottom: 1px;
left: 0.5em;
z-index: 1;
height: 1em;
font-size: 13px;
line-height: 3.5em;
color: #999;
white-space: nowrap;
cursor: text;
transition: all 0.1s ease;
font-family: "Open Sans", sans-serif;
height: 100%;
}
/* making exception for Budget */
.not-required-input {
padding: 1em;
border: 1px solid #ccc;
-webkit-box-shadow: inset 0 1px 0 #eee, #fff 0 1px 0;
box-shadow: inset 0 1px 0 #eee, #fff 0 1px 0;
border-radius: 5px;
width: 100%;
background-color: black;
color: lightgray;
}
.not-required-label {
position: absolute;
top: 0;
right: 1px;
bottom: 1px;
left: 0.5em;
z-index: 1;
height: 1em;
font-size: 13px;
line-height: 3.5em;
color: #999;
white-space: nowrap;
cursor: text;
transition: all 0.1s ease;
font-family: "Open Sans", sans-serif;
height: 100%;
}
.required-input:focus ~ .required-label,
.required-input:valid ~ .required-label {
font-size: 9px;
font-weight: bold;
left: 5px;
top: -5px;
}
/* making exception for Budget */
.not-required-input:focus ~ .not-required-label,
.not-required-input:invalid ~ .not-required-label {
font-size: 9px;
font-weight: bold;
left: 5px;
top: -5px;
}
.required-input:valid ~ .required-label {
color: #497495;
}
.required-input:focus:invalid ~ .required-label {
color: red;
}
.required-input:required ~ .required-label::before {
content: "*";
color: red;
}
.required-input:required:valid ~ .required-label::before {
color: #497495;
}
The only issue that I'm facing in this form is when selecting the (not-required) field which is (Budget) as you saw in the link after finish writing in that field or after it get unfocused, the label back to its old position and value!
Can you help me to figure out where is the mistake in the elements selection and what shall I do instead please?
Ps. when I set the input restriction of (Budget) to *required it will not have any problem!
You have :invalid for an element that can't be invalid. Since it doesn't have required, it will always come out as invalid. My answer comes from this blog.
#import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600);
* {
box-sizing: border-box;
}
/*Just to center the Form*/
form {
height: 100%;
width: 400px;
overflow: auto;
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
/* A container to position LABELS */
.container {
position: relative;
/* top: auto;
left: auto;
width: auto; */
}
/* making exception for Budget */
.not-required-input {
padding: 1em;
border: 1px solid #ccc;
-webkit-box-shadow: inset 0 1px 0 #eee, #fff 0 1px 0;
box-shadow: inset 0 1px 0 #eee, #fff 0 1px 0;
border-radius: 5px;
width: 100%;
background-color: black;
color: lightgray;
}
.not-required-label {
position: absolute;
top: 0;
right: 1px;
bottom: 1px;
left: 0.5em;
z-index: 1;
height: 1em;
font-size: 13px;
line-height: 3.5em;
color: #999;
white-space: nowrap;
cursor: text;
transition: all 0.1s ease;
font-family: "Open Sans", sans-serif;
height: 100%;
}
/* making exception for Budget */
.not-required-input:focus ~ .not-required-label,
.not-required-input:invalid ~ .not-required-label,
.not-required-input:not(:placeholder-shown) ~ .not-required-label {
font-size: 9px;
font-weight: bold;
left: 5px;
top: -5px;
}
<form action="">
<div class="container" >
<input class="not-required-input" type="text" id="budget" placeholder=""/>
<label class="not-required-label" for="budget">Budget:</label>
</div>
<input type="submit" value="Submit">
</form>
What I have done is add .not-required-input:not(:placeholder-shown) ~ .not-required-label to your CSS and placeholder="" to the HTML. Of course, placeholders disappear when the user types into the input, so the pseudo :not(:placeholder-shown) will fire when user types into the input. I have only tested this in Firefox but it should work for all browsers. If needed, you can add a space into the placeholder for cross-browser support.
I would like to create an triangle label inside input (text) element exactly like this:
What I managed to do so far is this:
How can I put this triangle "under" the input border to, let's just say, keep border radius from input cutting the edge of this triangle?
This is my code:
<div class="input">
<label>email adress</label>
<div class="note">
<p>*</p>
<input type="text" placeholder="Enter your email adress">
</div>
</div>
.input {
display: flex;
flex-direction: column;
width: 100%;
}
.note > input {
width: 515px;
height: 48px;
border-radius: 5px;
border: 1px solid #7d7d7d;
box-shadow:inset 0 0 5px 1px lightgray;
padding-left: 20px;
color: #acacac;
-webkit-color: #acacac;
-moz-color: #acacac;
-ms-color: #acacac;
-o-color: #acacac;
font-size: 16px;
background-color: rgba(211, 211, 211, 0.50);
}
.note > input:focus {
outline: none;
background-color: #f9f9f9;
}
.note {
position: relative;
display: inline-block;
}
.note:after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
display: block;
border-left: 35px solid transparent;
border-bottom: 35px solid transparent;
border-top: 35px solid #0094bb;
}
I imagine there is no way to give border-radius to this triangle itself without losing its shape, am I right?
I added position absolute for your P tag and postioned it in the corner.
The border radius is achieved by adding a border radius to your .note wrapper and setting overflow:hidden.
.note > input {
width: 515px;
height: 48px;
border-radius: 5px;
border: 1px solid #7d7d7d;
box-shadow:inset 0 0 5px 1px lightgray;
padding-left: 20px;
color: #acacac;
-webkit-color: #acacac;
-moz-color: #acacac;
-ms-color: #acacac;
-o-color: #acacac;
font-size: 16px;
background-color: rgba(211, 211, 211, 0.50);
}
.note > input:focus {
outline: none;
background-color: #f9f9f9;
}
.note {
position: relative;
display: inline-block;
border-radius: 5px;
overflow:hidden;
}
.note:after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
display: block;
border-left: 35px solid transparent;
border-bottom: 35px solid transparent;
border-top: 35px solid #0094bb;
z-index:0;
}
.note p{
position: absolute;
right: 5px;
top: 5px;
color:white;
z-index:1;
margin:0;
padding:0;
}
label {
display:block;
}
<div class="input">
<label>email address</label>
<div class="note">
<p>*</p>
<input type="text" placeholder="Enter your email adress">
</div>
</div>
Consider declaring the pseudo-element to a nested element of .note instead.
This will allow you to specify the required border-radius property on the containing element rather than the pseudo-element. With an overflow: hidden rule declared on this new containing element in addition, the top-right corner of the pseudo-element will be "cut-off" from view, conveying the impression that this is an element nested within the input field.
Code Snippet Demonstration:
.note > input {
width: 515px;
height: 48px;
border-radius: 5px;
border: 1px solid #7d7d7d;
box-shadow:inset 0 0 5px 1px lightgray;
padding-left: 20px;
color: #acacac;
-webkit-color: #acacac;
-moz-color: #acacac;
-ms-color: #acacac;
-o-color: #acacac;
font-size: 16px;
background-color: rgba(211, 211, 211, 0.50);
}
.note > input:focus {
outline: none;
background-color: #f9f9f9;
}
.note {
position: relative;
display: inline-block;
}
/* additional */
.note .required {
position: absolute;
top: 0;
right: 0;
z-index: 1;
color: white;
padding: 5px;
box-sizing: border-box;
border-top-right-radius: 5px;
overflow: hidden;
width: 35px;
height: 35px;
text-align: right;
}
.note .required:after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
display: block;
border-left: 35px solid transparent;
border-bottom: 35px solid transparent;
border-top: 35px solid #0094bb;
z-index: -1;
}
<div class="input">
<label>email adress</label>
<div class="note">
<span class="required">*</span>
<input type="text" placeholder="Enter your email adress">
</div>
</div>
The closest i could get with your solution. But I found other ways you're satisfied with this okay...
.note > input {
width: 515px;
height: 48px;
border-radius: 5px;
border: 1px solid #7d7d7d;
box-shadow:inset 0 0 5px 1px lightgray;
padding-left: 20px;
color: #acacac;
-webkit-color: #acacac;
-moz-color: #acacac;
-ms-color: #acacac;
-o-color: #acacac;
font-size: 16px;
background-color: rgba(211, 211, 211, 0.50);
}
.note > input:focus {
outline: none;
background-color: #f9f9f9;
}
.note {
position: relative;
display: inline-block;
}
.note:after {
content: "";
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
display: block;
line-height: 48px;
text-align: top;
border-left: 35px solid transparent;
border-bottom: 35px solid transparent;
border-top: 35px solid #0094bb;
}
.note::before {
content: "*";
position: absolute;
right: 7px;
z-index: 1;
top: 5px;
color: white;
}
<div class="input">
<label>email adress</label>
<div class="note">
<input type="text" placeholder="Enter your email adress">
</div>
</div>
I created a dropdown with just pure css, but the problem is that it is pushing the other content downwards. Can someone help out?
HTML:
<div class="select">
<input id="is-focus" type="radio" name="item" />
<label for="is-focus"><span class="label"></span></label>
<ul class="options">
<li>
<input type="radio" name="item" value="pie" id="pie" />
<label for="pie" data-title="Pie">Pie</label>
</li>
<li>
<input type="radio" name="item" value="cake" id="cake" />
<label for="cake" data-title="Cake">Cake</label>
</li>
</ul>
</div>
CSS:
.select {
position: relative;
overflow: hidden;
}
.select .label {
padding: 8px;
max-width: 150px;
}
.select .label:after {
content: "";
position: absolute;
left: 12px;
top: 14px;
border: 8px solid transparent;
border-top-color: #999;
}
.select label {
max-width: 150px;
display: block;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 3px;
padding: 8px;
cursor: pointer;
}
.select .options {
max-width: 220px;
margin: 0;
padding: 0;
color: #666;
height: 0;
border-right: 1px dotted #999;
border-left: 1px dotted #999;
border-radius: 5px;
max-height: 162px;
overflow-y: auto;
overflow-x: hidden;
}
.select .options:hover {
height: auto;
border-bottom: 2px solid #999;
}
.select .options li label {
text-align: left;
display: block;
padding: 6px 220px 6px 15px;
cursor: pointer;
overflow: hidden;
box-sizing: border-box;
}
.select .options li label:hover {
background-image: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
}
.select .options li [type="radio"] {
position: absolute;
display: block;
left: -999px;
}
.select .options li [type="radio"]:checked ~ label:after {
content: attr(data-title);
display: block;
position: absolute;
top: 6px;
left: 20px;
padding: 5px 25px;
color: #666;
pointer-events: none;
font-size: 80%;
overflow: hidden;
}
.select #is-focus {
position: absolute;
display: block;
opacity: 0;
left: 150px;
}
.select #is-focus:focus ~ label span.label:after {
border-top-color: transparent;
border-bottom-color: #999;
top: 0.3em;
}
.select #is-focus:focus ~ .options {
height: auto;
border-bottom: 2px solid #999;
}
Here is a codepen link for what I am trying to do:
http://codepen.io/anon/pen/ogYKzQ
Thank You
Change the .options position from static to fixed
and add a white background to the menu labels.
Figured it out. Set the position of .select to absolute, set the background of label to white, and added a z-index to it.
I am trying to get my search box to work but the box is showing on top of my and the css i gave for my fieldset. it looks like the original text input box is on top of the modified fieldset text box (which i want to use for my wesite). the fieldset box is longer ans perfect but i cannot type into that box because the original small box is on top of the fieldset css. thank you
index:
<form id="search-form" action="/properties/search" method="get">
<fieldset>
<input type ="text "name="q" placeholder="Search for a Website" autocomplete="off">
<button type="button" data-hasqtip="5" oldtitle="search" title aria- describedby="qtip-5"> </button>
</fieldset>
</form>
css:
#search-form {
display: block;
margin-top: 9px;
float: left;
}
#search-form fieldset {
position: relative;
width: 425px;
height: 22px;
padding: 0;
background-color: #fdfdfd;
border: 1px solid #ced8dd;
}
#search-form input[type="text"] {
position: relative;
font-size: .8125em;
line-height: 1.3846153846153846;
padding: 0;
margin: 2px 0 0 5px;
border-width: 0;
width: 380px;
}
search-form button {
position: absolute;
right: 0;
width: 18px;
height: 16px;
padding: 0;
margin: 3px 3px 0 0;
border: 0;
border-left: 1px solid #ced8dd;
background-color: #fdfdfd;
background-repeat: no-repeat;
background-image: url("http://images.househappy.org/icon_sprite_1x_v14.png");
background-position: -10px -22px;
}
It's been said in the comments, but really all you need to do is clean up your code.
Have a fiddle!
HTML
<form id="search-form" action="/properties/search" method="get">
<fieldset>
<input type="text" name="q" placeholder="Search for a Website" autocomplete="off" />
<button type="button" data-hasqtip="5" oldtitle="search"> </button>
</fieldset>
</form>
CSS
#search-form {
display: block;
margin-top: 9px;
float: left;
}
#search-form fieldset {
position: relative;
width: 425px;
height: 22px;
padding: 0;
background-color: #fdfdfd;
border: 1px solid #ced8dd;
}
#search-form input[type="text"] {
position: relative;
font-size: .8125em;
line-height: 1.3846153846153846;
padding: 0;
margin: 2px 0 0 5px;
border-width: 0;
width: 380px;
}
#search-form button {
position: absolute;
right: 0;
width: 18px;
height: 16px;
padding: 0;
margin: 3px 3px 0 0;
border: 0;
border-left: 1px solid #ced8dd;
background-color: #fdfdfd;
background-repeat: no-repeat;
background-image: url("http://images.househappy.org/icon_sprite_1x_v14.png");
background-position: -10px -22px;
}
I want to achieve the following shapes using pure CSS, no images.
I've come to the following point.
Here is the HTML structure:
<div class="sixteen columns">
<div id="applicationStatus">
<ul>
<li class="applicationStatus">Application Received</li>
<li class="applicationStatusGood">Language Exam</li>
<li class="applicationStatusNoGood">Oral Exam</li>
<li class="applicationStatus">Grant</li>
</ul>
</div>
</div>
And here is the CSS:
#applicationStatus {
position: relative;
width: auto;
height: 140px;
left: 40px; }
ul.applicationStatus {
list-style: none; }
li.applicationStatus, li.applicationStatusGood, li.applicationStatusNoGood {
height: 140px;
background-color: #767676;
display: inline-block;
/* Dirty IE Hack */
zoom: 1;
*display: inline;
margin-right: 30px;
margin-left: 30px;
padding: 10px;
color: white;
font-size: 18px;
text-align: center;
line-height: 150px;
/* vertical-align: middle; */ }
li.applicationStatus:after, li.applicationStatusGood:after, li.applicationStatusNoGood:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-top: 80px solid transparent;
border-left: 30px solid #767676;
border-bottom: 80px solid transparent;
margin: -10px 90px 0 10px; }
li.applicationStatus:before, li.applicationStatusGood:before, li.applicationStatusNoGood:before {
content: "";
position: absolute;
width: 0;
height: 0;
left: 0px;
border-top: 80px solid transparent;
border-left: 30px solid white;
border-bottom: 80px solid transparent;
margin: -10px 0px 0 0px; }
li.applicationStatus:first-child, li.applicationStatusGood:first-child, li.applicationStatusNoGood:first-child {
margin-left: 0px;
text-indent: 30px; }
li.applicationStatus:last-child, li.applicationStatusGood:last-child, li.applicationStatusNoGood:last-child {
border-top: 0px solid transparent;
border-left: 0px solid transparent;
border-bottom: 0px solid transparent; }
li.applicationStatusGood {
background-color: #77a942; }
li.applicationStatusGood:after {
border-left: 30px solid #77a942; }
li.applicationStatusNoGood {
background-color: #c42c00; }
li.applicationStatusNoGood:after {
border-left: 30px solid #c42c00; }
Why doesn't the :before selector apply to all of the shapes or all in all how can I achieve what I want?
Modification of Your Code
The main issue you faced was not having position: relative on your li elements. But there were other things that needed tweaking too.
Here is a fiddle example to see.
I added the class you failed to reference in your HTML above to the ul element, so here is the HTML:
<div class="sixteen columns">
<div id="applicationStatus">
<ul class="applicationStatus">
<li class="applicationStatus">Application Received</li>
<li class="applicationStatusGood">Language Exam</li>
<li class="applicationStatusNoGood">Oral Exam</li>
<li class="applicationStatus">Grant</li>
</ul>
</div>
</div>
Then I modified your CSS a bit to condense it (could be more condensed if CSS3 only was being supported):
#applicationStatus {
position: relative;
width: auto;
height: 140px;
left: 40px; }
.applicationStatus li { /* Added this and moved much code to here */
position: relative; /* this was a key property missing from your code */
text-indent: 30px;
height: 140px;
background-color: #767676;
display: inline-block;
/* Dirty IE Hack */
zoom: 1;
*display: inline;
/* margin-right: 30px; Eliminated this */
margin-left: 30px;
padding: 10px 10px 10px 30px; /* tweaked this */
color: white;
font-size: 18px;
text-align: center;
line-height: 150px;
}
ul.applicationStatus { /* this was irrelevant with the HTML you gave, but I added the class to the ul */
list-style: none; }
/* tweaked various things below here */
li.applicationStatus:first-child:after, li.applicationStatusGood:after, li.applicationStatusNoGood:after {
content: "";
position: absolute;
width: 0;
height: 0;
border-top: 80px solid transparent;
border-left: 30px solid #767676;
border-bottom: 80px solid transparent;
margin: -10px 90px 0 10px;
}
li.applicationStatus:last-child:before, li.applicationStatusGood:before, li.applicationStatusNoGood:before {
content: "";
position: absolute;
width: 0;
height: 0;
left: 0;
border-top: 80px solid transparent;
border-left: 30px solid white;
border-bottom: 80px solid transparent;
margin: -10px 0px 0 0px;
}
li.applicationStatus:first-child {
padding-left: 10px;
margin-left: 0;
}
li.applicationStatus:last-child {
padding-right: 30px;
}
li.applicationStatusGood {
background-color: #77a942; }
li.applicationStatusGood:after {
border-left: 30px solid #77a942; }
li.applicationStatusNoGood {
background-color: #c42c00; }
li.applicationStatusNoGood:after {
border-left: 30px solid #c42c00; }
U can try this website.
http://cssarrowplease.com/
.arrow_box {
position: relative;
background: #88b7d5;
border: 8px solid #c2e1f5;
}
.arrow_box:after, .arrow_box:before {
left: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(136, 183, 213, 0);
border-left-color: #88b7d5;
border-width: 30px;
top: 50%;
margin-top: -30px;
}
.arrow_box:before {
border-color: rgba(194, 225, 245, 0);
border-left-color: #c2e1f5;
border-width: 41px;
top: 50%;
margin-top: -41px;
}