I have a 2 text boxes. when I focus on 1st textbox. I get border but when I focus on 2nd textbox I don't get border-top. I have given border-top:none to the 2nd textbox as 1st textbox's border-bottom mixes with the 2nd textbox border-top.
I want to solve this issue using only CSS3.
.form-control{
padding:6px 12px;
border:thin black solid;
}
.form-control:focus{
border:thin green solid;
}
.add_url .form-control{
padding:6px 12px;
border:thin black solid;
border-top:none;
}
.add_url .form-control:focus{
border:thin green solid;
border-top:none;
}
<input type="text" class="form-control" placeholder="enter url 1">
<div class="add_url">
<input type="text" class="form-control" placeholder="enter url 2">
</div>
PS : When I focus on any of the text box , I should get border to be green to all around the textbox.
Any help would be great.
Thank you.
Don't hide the 2nd box border, just position it under the 1st. When one of the boxes is focused use the outline to highlight it, and bring it to the top, so it won't be under the other box:
.form-control {
position: relative;
padding: 6px 12px;
border: thin black solid;
}
.form-control:focus {
border: thin green solid;
}
.add_url .form-control {
top: -1px;
padding: 6px 12px;
border: thin black solid;
}
.form-control:focus {
outline: 1px green solid;
outline-offset: -1px;
z-index: 1;
}
<input type="text" class="form-control" placeholder="enter url 1">
<div class="add_url">
<input type="text" class="form-control" placeholder="enter url 2">
</div>
i think this is the best way :
HTML :
<input type="text" placeholder="enter url 1">
<div class="add_url">
<input type="text" placeholder="enter url 2">
</div>
CSS :
input {
padding:6px 12px;
border:2px black solid;
outline: 0;
position: relative;
z-index: 0;
}
input:focus{
border:2px green solid;
z-index: 1;
}
.add_url input { margin-top: -2px; }
Example: Create an form-control:focus in css and set the border as green and outline:none and z-index:1
.form-control{
padding:6px 12px;
border:thin black solid;
}
.form-control:focus {
padding:6px 12px;
border:thin green solid;
outline:none;
z-index:1;
}
<div class="add_url">
<input type="text" class="form-control" placeholder="enter url 1">
<input type="text" class="form-control" placeholder="enter url 2">
</div>
Related
How Can I delete the black border when clicking on any input??
Here is my HTML
<div class="info">
<input class="forms" type="text" placeholder="First Name.">
<input class="forms" type="email" placeholder="Email Adress.">
<input class="forms" type="tel" placeholder="Phone Number (optional)">
<input id="submitbtn" type="button" value="SUBMIT MESSAGE">
</div>
AND here is css
.forms {
margin-bottom: 30px;
font-size: 20px;
color: blue;
padding: 0px;
padding-bottom: 14px;
width: 440px;
border: none;
background-color: transparent;
border-bottom: 4px solid black;
}
.forms::placeholder {
color: rgba(0, 41, 255, 0.42);
}
Add the following code you your CSS and your problem will be solved
input:focus{
outline: none;
}
It's important to note that disabling an input element's outline is not recommended as it hinders accessibility. The outline property is there for a reason - providing users with a clear indication of keyboard focus. For further go through this link http://outlinenone.com/
I'm currently struggling with an aesthetic problem. My triangle button is being cut off at the right corner and it's not a sight, it's basically a right-sided trapezium.
What i did was make an input field, and aligned a triangle submit button at the end of the input field.
What's the cause of this?
.submit_btn {
display: block;
grid-row: 1;
grid-column: 1;
width: 0;
height: 0;
border-style: solid;
border-width: 10px 0 10px 17.3px;
border-color: transparent transparent transparent #bc2ac1;
background-color: transparent;
align-self: center;
justify-self: flex-end;
cursor: pointer;
}
.submit_btn:focus {
outline: none;
}
<form class="form_name" action="">
<label class="name" for="name">What's your name?</label>
<div class="input_wrapper">
<input class="name_field" type="text" name="name" placeholder="Your name">
<input class="submit_btn" type="submit" value="">
</div>
</form>
Default padding on your input element was interfering with the cool CSS border trick. Add:
padding: 0;
I changed the element to a <button> and removed all the code not directly related to styling the purple triangle. I also reformatted the triangle border trick code to make it a little clearer. This is all for demo purposes. Just adding the padding line to your code will fix it.
.submit_btn {
/* this fixes the tip of the triangle */
padding: 0;
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 17.3px solid #bc2ac1;
border-right: none;
cursor: pointer;
}
<form class="form_name" action="">
<label class="name" for="name">What's your name?</label>
<div class="input_wrapper">
<input class="name_field" type="text" name="name" placeholder="Your name">
<button class="submit_btn" type="submit" value=""></button>
</div>
</form>
Add display: flex to the main container to move your triangle to right and for moving your triangle to in input field, I used translateY property.
.input_wrapper {
display: flex;
}
.submit_btn {
display: block;
grid-row: 1;
grid-column: 1;
width: 0;
height: 0;
border-style: solid;
border-width: 10px 0 10px 17.3px;
border-color: transparent transparent transparent #bc2ac1;
background-color: transparent;
align-self: center;
justify-self: flex-end;
cursor: pointer;
transform: translateX(-25px);
}
.submit_btn:focus {
outline: none;
}
<form class="form_name" action="">
<label class="name" for="name">What's your name?</label>
<div class="input_wrapper">
<input class="name_field" type="text" name="name" placeholder="Your name">
<input class="submit_btn" type="submit" value="">
</div>
</form>
I was wondering if it's possible to change the shape of a text box, so it would be a rectangle but with the beginning of it 'taken out' ? I attached an example image.
I found about clip-path: polygon in css but it only accepts four coordinates.
Thanks in advance!
Check below codes see if this is what you want:
.field {
position: relative;
margin-bottom: 20px;
}
.field label {
position: absolute;
min-width: 100px;
border: 1px solid;
border-top-color: #fff;
border-left-color: #fff;
}
.field input[type="text"] {
padding: 10px 10px 10px 110px;
border: 1px solid;
outline: none;
}
<div class="field">
<label for="status">Status</label>
<input type="text" id="status">
</div>
<div class="field">
<label for="givenname">Given Name</label>
<input type="text" id="givenname">
</div>
<div class="field">
<label for="surname">SurName</label>
<input type="text" id="surname">
</div>
This is the image which shows my problem >> https://imgur.com/a/YpvMAYq << Here's my html code:
.form-control {
width: 600px;
fill: none;
background: transparent;
border: none;
border-bottom: 1px solid grey;
font-size: 18px;
margin-bottom: 16px;
}
<form id="contactForm" method="POST" action="">
<input name="fName" type="text" class="form-control" placeholder="What should I call you? Person X?" required>
<br>
<input name="email" type="email" class="form-control" placeholder="Only, if you want to be emailed back">
<br>
</form>
Thank you for reading this ;)
As I mentioned in a comment, it looks like a background is being set when the input is in a certain state. It looks like your using a framework and it is impossible to tell without the code used there, or a codepen/jsfiddle.
The css below will set the background to transparent when the input is in focus or active states.
.form-control:focus, .form-control:active {
background: transparent;
}
Check out this question for information on input states.
In css code instead you can add
background-color:transparent;
Try this
form{
background: #000;
}
.form-control {
width: 600px;
fill: none;
background: transparent;
border: none;
border-bottom: 1px solid gray;
font-size: 18px;
margin-bottom: 16px;
}
input:focus {
background-color: #fff;
border: 2px solid #000;
padding: 20px;
border-radius: 10px;
}
<form id="contactForm" method="POST" action="">
<input name="fName" type="text" class="form-control" placeholder="What should I call you? Person X?" required>
<br>
<input name="email" type="email" class="form-control" placeholder="Only, if you want to be emailed back">
<br>
</form>
I have few input fields on which i have given some border rounding. The problem I am facing is that a shadow appears on the right and bottom of the field. I want to control the width of it along with color and some other properties. I have used box shadow properties but that creates another shadow instead of removing or styling this one. So what is this little thing if it's not a box shadow and how to style it..
.options {
width:40px;
text-align:center;
margin-left:30px;
border-radius: 5px;
border-style:outset;
box-shadow: none;
}
<input type="text" class="options" id="3" name="1" value="3" readonly>
Fiddle
This is the default behavior for border-style:outset. You should overwrite it with something like solid.
.options {
width:40px;
text-align:center;
margin-left:30px;
border-radius: 5px;
border: solid 1px grey;
}
<input type="text" class="options" id="3" name="1" value="3" readonly />
Add border:none; or add border:1px solid grey; on your class
.options {
width:40px;
text-align:center;
margin-left:30px;
border-radius: 5px;
border-style:outset;
box-shadow: none;
border:none;
}
or
.options {
width:40px;
text-align:center;
margin-left:30px;
border-radius: 5px;
border-style:outset;
box-shadow: none;
border:1px solid grey;
}