Border doesn't display in CSS, why? - html

I tried to add a border to the input but the border doesn't display. I don't know what the problem could be. Does anyone see something that I don't?
HTML:
<div class="word">
<div class="search">
<span class="text">Search</span>
<input type="text" placeholder="Enter word to search">
<button><i class="fas fa-search"></i></button>
</div>
</div>
And CSS:
.word .search input{
position: absolute;
height: 42px;
width: calc(100% - 50px);
font-size: 16px;
padding: 0 13px;
border: 1px solid #e6e6e6 !important;
outline: none;
border-radius: 5px 0 0 5px;
opacity: 0;
pointer-events: none;
transition: all 0.2s ease;
}

just remove the opacity or make it 1
<div class="word">
<div class="search">
<span class="text">Search</span>
<input type="text" placeholder="Enter word to search">
<button><i class="fas fa-search"></i></button>
</div>
</div>
<style>
.word .search input{
position: absolute;
height: 42px;
width: calc(100% - 50px);
font-size: 16px;
padding: 0 13px;
border: 1px solid #e6e6e6 !important;
outline: none;
border-radius: 5px 0 0 5px;
/*opacity: 0;*/
pointer-events: none;
transition: all 0.2s ease;
}
</style>

I am not sure I understand precisely what you are trying to do but as stated in previous answers if you set the opacity to 0 the entire input including the border will be transparent/not visible. The search bar doesn't seem to do much in the code you provided as the pointer-events: none; results in the search bar being impossible to select.
So if you want a search bar with a border but with a transparent background, and it being clickable I would suggest the following:
.word{
background: lightgrey;
}
.search input{
border: 2px solid #000;
border-radius: 5px 0 0 5px;
background: transparent;
}
<div class="word">
<div class="search">
<span class="text">Search</span>
<input type="text" placeholder="Enter word to search">
<button><i class="fas fa-search"></i>button</button>
</div>
</div>

Related

How to create material design input form using css and bootstrap?

I want to design following material design input form using css and bootstrap. Following code is I am currently using. But it doesn't provide exact result I want.
Code Pen Link : View Source Code Here
HTML CODE :
<div class="container">
<h2>Google Material Design in CSS3<small>Inputs</small></h2>
<form>
<div class="group">
<input type="text" required>
<span class="highlight"></span>
<span class="bar"></span>
<label>Name</label>
</div>
<div class="group">
<input type="text" required>
<span class="highlight"></span>
<span class="bar"></span>
<label>Email</label>
</div>
</form>
<p class="footer">
a tutorial by scotch.io
</p>
</div>
But I want this design :
CSS Only solution; use combination of sibling selector ~ on the label and :valid pseudo selector on the input.
body {
margin: 10px;
}
.form-group>label {
bottom: 34px;
left: 15px;
position: relative;
background-color: white;
padding: 0px 5px 0px 5px;
font-size: 1.1em;
transition: 0.2s;
pointer-events: none;
}
.form-control:focus~label {
bottom: 55px;
}
.form-control:valid~label {
bottom: 55px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-md-6">
<br>
<div class="form-group">
<input type="text" class="form-control" id="usr" required>
<label for="usr">Name</label>
</div>
<div class="form-group">
<input type="text" class="form-control" id="password" required>
<label for="usr">Password</label>
</div>
</div>
</div>
</div>
Since you've tagged Bootstrap 4, I'm assuming you wanted the solution with regards to that framework.
Setup a default form-group, label, and input markup like this;
<div class="form-group">
<label for="usr">Name:</label>
<input type="text" class="form-control" id="usr">
</div>
Then add this css, what this would do is
position label relative to its container (form-group)
then we specified the top and left positions so that it would land
on top of the input field
I added a white background and padding to the label so that it would have a box around the label.
.form-group > label {
top: 18px;
left: 6px;
position: relative;
background-color: white;
padding: 0px 5px 0px 5px;
font-size: 0.9em;
}
Here's a fiddle with that code on bootstrap 4;
http://jsfiddle.net/rw29jot4/
For the animation, check this fiddle, we need to utilize click events and move the position of the label;
Updated code with animation;
http://jsfiddle.net/sedvo037/
EDIT: Please see my answer below which uses only CSS.
Try with this code.
HTML:
<div class="main_div">
<div class="group">
<input type="text" required="required"/>
<label>Name</label>
</div>
</div>
CSS:
.main_div{
padding: 30px;
}
input,
textarea {
background: none;
color: #c6c6c6;
font-size: 18px;
padding: 10px 10px 10px 15px;
display: block;
width: 320px;
border: none;
border-radius: 10px;
border: 1px solid #c6c6c6;
}
input:hover{
border: 3px solid black;
}
input:focus,
textarea:focus {
outline: none;
border: 3px solid black;
}
input:focus ~ label, input:valid ~ label,
textarea:focus ~ label,
textarea:valid ~ label {
top: -5px;
font-size: 12px;
color: #000;
left: 11px;
}
input:focus ~ .bar:before,
textarea:focus ~ .bar:before {
width: 320px;
}
input[type="password"] {
letter-spacing: 0.3em;
}
.group{
position: relative;
}
label {
color: #c6c6c6;
font-size: 16px;
font-weight: normal;
position: absolute;
pointer-events: none;
left: 15px;
top: 12px;
transition: 300ms ease all;
background-color: #fff;
padding: 0 2px;
}

How can I configure my css so that a span's height matches the adjacent input's height (Hubspot)?

Here's the result that I'm trying to fix:
As you can see, the span with the percent symbol is stretching to fit the margin that is on the input. How can I prevent this? I've tried multiple css attributes but can't seem to break the span out of taking on the input's excess margin.
This is created using Hubspot CMS and I've had to try and recreate the bootstrap styling on my normal site.
Here is the markup:
<div class="row">
<div class="col-sm-6">
<label for="monthly-traffic" class="control-label">Monthly traffic (unique visitors)</label>
<input class="form-control" type="number" name="monthly-traffic" id="monthly-traffic" class="form-control" placeholder="monthly traffic">
</div>
<div class="col-sm-6">
<label for="percent-us" class="control-label">Percent of traffic from US</label>
<div class="input-group">
<input id="percent-us-addon" class="form-control" type="number" name="percent-us" placeholder="US traffic percentage" aria-describedby="percent-us-addon">
<span class="input-group-addon">%</span>
</div>
</div>
</div>
and the css for:
col-sm-6: {
width: 50%;
float: left;
position: relative;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
}
input-group: {
border-left: 0;
border-bottom-left-radius: 0;
border-top-left-radius: 0;
position: relative;
display: table;
border-collapse: separate;
}
form-control: {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
vertical-align: middle;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
and
input-group-addon:{
padding: 6px 12px;
font-size: 14px;
font-weight: 400;
line-height: 1;
color: #555;
text-align: center;
background-color: #e2e2e2;
border: 1px solid #ccc;
border-radius: 4px;
width: 1%;
white-space: nowrap;
vertical-align: middle;
display: table-cell;
}
Your markup is missing the .input-group wrapper and the appropriate addon classes (.input-group-append and .input-group-text).
With this markup, you should not need any custom CSS at all:
<label for="percent-us" class="control-label">Percent of traffic from US</label>
<div class="input-group">
<input id="percent-us-addon" class="form-control" type="number" name="percent-us" placeholder="US traffic percentage" aria-describedby="percent-us-addon">
<div class="input-group-append">
<span class="input-group-text">%</span>
</div>
</div>
Full codepen # https://codepen.io/cfxd/pen/ywbjxZ

background color on search glyphicon

I'm trying to get my the background color on my search glyph to take up the full box. Ideally, it should look like this.
However, it currently looks like this.
I'm not sure what's going on.
Here's my html (I'm using Bootstrap).
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-6">
<div id="custom-search-input">
<div class="input-group col-md-12">
<input type="text" class="form-control input-lg" placeholder="Search by user name, member types, genres..." />
<span class="input-group-btn">
<button class="btn btn-info btn-lg" type="button">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
</div>
</div>
Edited to add my CSS:
#custom-search-input{
padding: 3px;
border: solid 1px #E4E4E4;
border-radius: 6px;
background-color: #fff;
height: 75%;
}
#custom-search-input input{
border: 0;
box-shadow: none;
}
.input-group-btn{
background: #E44424;
}
#custom-search-input button{
margin: 2px 0 0 0;
background: #E44424;
box-shadow: none;
border: 0;
color: black;
padding: 0 8px 0 10px;
border-left: solid 1px #ccc;
}
#custom-search-input button:hover{
border: 0;
box-shadow: none;
border-left: solid 1px #ccc;
}
#custom-search-input .glyphicon-search{
font-size: 23px;
}
You have padding in
#custom-search-input{
padding: 3px;
}
That's the reason.
You should instead have it on
.form-control{
padding: 3px;
}
if you need padding on input
Here's Plunker

HTML Search element styling

I´m trying to build a search element together with a button, something like:
Except that I need to change the background color of the search icon (blue, gray, whatever...).
Here is my code so far and the result:
.searchWrap {
position: absolute;
border: thin solid #f2f2f2;
border-radius: 5px;
top: 5px;
left: 5px;
}
.searchTerm {
float: left;
border-style: none;
padding: 5px;
height: 20px;
outline: none;
}
.searchButton {
right: -50px;
width: 30px;
height: 20px;
border: 1px solid #f2f2f2;
background: #f2f2f2;
border-radius: 5px;
text-align: center;
color: #ccc;
vertical-align: middle;
cursor: pointer;
}
<div className="searchWrap">
<input type="text" className="searchTerm" placeholder="Search..." />
<button type="submit" className="searchButton">
<Icon name='search' />
</button>
</div>
I'm using React. Here is my result so far:
The external border is rounded, ok, that's what I need, but the separation between the searchTerm and the searchButton is also rounded, and I need a plain separator here, something like:
I'm using font awesome here, so the code isn't spaced like your screenshot, but looks like you have your own library you're using with react for that icon and your spacing is fine.
All you need to do is use border-radius: 0 5px 5px 0 to keep the left side borders from rounding, and assign a border-left on the .searchButton to draw the vertical line. I changed the border color so it's more prominent, but you can use whatever color you want.
*{margin:0;padding:0;}
.searchWrap {
position: absolute;
top: 5px;
left: 5px;
}
.searchTerm {
float: left;
border-style: none;
padding: 5px;
height: 20px;
outline: none;
margin-left: 3px;
border: thin solid #ddd;
border-width: thin 0 thin thin;
border-radius: 5px 0 0 5px;
}
.searchButton {
right: -50px;
width: 30px;
height: 32px;
border: 1px solid #f2f2f2;
background: #f2f2f2;
border-radius: 0 5px 5px 0;
text-align: center;
color: #ccc;
vertical-align: middle;
cursor: pointer;
border: thin solid #ddd;
}
.searchTerm:focus, .searchTerm:focus + .searchButton {
border-color: red;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="searchWrap">
<input type="text" class="searchTerm" placeholder="Search..." />
<button type="submit" class="searchButton">
<i class="fa fa-search"></i>
</button>
</div>
Try this for the search button css instead of border-radius
.searchButton {
...
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
...
}
Can you use bootstrap? Relatively simple, and once you have it, modify the css the way you want it.
https://v4-alpha.getbootstrap.com/components/input-group/#button-addons
Bootstrap is strongly recommended for this. See http://getbootstrap.com/components/#input-groups. Coupled with FontAwesome, you could do something like this:
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="fa fa-search"></span>
<span class="sr-only">Search</span>
</button>
</span>
</div>

Positioning div right under an a tag

I'm trying to make a drop down menu to appear right under the URL that opens it up. So far I've managed to make a menu appear, but I can't figure out how to position it properly. My HTML looks like this
<div id="container">
Content here
<div class="line-gray-footer"></div>
<div class="footer">
Link 1 | <a id="langSwitch">English ▼</a>
<div id="dropdown" class="drop-choices">
<a class="choice" href="/de">Deutsch</a>
<a class="choice" href="/fr">Français</a>
<a class="choice" href="/it">Italiano</a>
<a class="choice" href="/es">Español</a>
</div>
</div>
<div class="morestuff">
<table>
<tr>
<th>Test</th><th>Test</th>
</tr>
<tr>
<td>A</td><td>b</td>
</tr>
</table>
</div>
</div>
CSS
#container{
width:70%;
background: red;
margin: 0 auto;
height:800px;
}
.line-gray-footer {
background: #ececec none repeat scroll 0 0;
height: 3px;
margin: 10px 10px;
}
.footer {
text-align: center;
}
.drop-choices.inuse {
opacity: 1;
visibility: visible;
display: block;
}
.drop-choices {
background-color: white;
border: 1px solid gray;
border: medium none;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
display: none;
line-height: normal;
margin-top: 0;
opacity: 0;
position: absolute;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0s;
visibility: hidden;
white-space: nowrap;
z-index: 100;
}
.drop-choices a.choice {
border-bottom: 1px solid #edf1f3;
color: #777;
padding: 3px 12px;
transition: all 0.1s ease 0s;
cursor: pointer;
display: block;
padding: 2px 3px 1px;
}
.morestuff table{
width: 100%;
border: 1px solid black;
}
Here is a jsFiddle URL of the whole thing https://jsfiddle.net/jaktav3t/
You just put parent div and set display: inline-block it will work
<div class="footer">
Link 1 | <div style="display: inline-block">
<a id="langSwitch">English ▼</a>
<div id="dropdown" class="drop-choices">
<a class="choice" href="/de">Deutsch</a>
<a class="choice" href="/fr">Français</a>
<a class="choice" href="/it">Italiano</a>
<a class="choice" href="/es">Español</a>
</div>
</div>
</div>
Add left:50%; in .drop-choices class so it will display in center of the div and also below of the dropdown.