I'm having the following template:
<div class="smallCard">
<p-card class="centered">
<p-header>
<img width="200" height="100" src="assets/images/vendor.svg" />
</p-header>
<p-messages></p-messages>
<span class="ui-float-label">
<input id="username" type="text" pInputText [(ngModel)]="username" required>
<label for="username">{{'Username' | translate}}</label>
</span>
<br>
<span class="ui-float-label">
<input id="password" type="password" pPassword [feedback]="false" [(ngModel)]="password" required />
<label for="password">{{'Password' | translate}}</label>
</span>
<br>
<p-checkbox name="permanent" value="true" label="{{'Remember me' | translate}}" [(ngModel)]="isPermanent">
</p-checkbox>
<p-footer>
<p-button label="Login" (onClick)="login()"></p-button>
</p-footer>
</p-card>
</div>
Where as the important css classes are:
.centered
{
text-align: center;
}
.smallCard
{
margin-top: 20%;
margin-left: 40%;
margin-right: 40%;
}
Which results in:
Obviously the labels aren't centered / aligned with the inputs. But how do I achieve this with primeng's float labels?
The label should have an absolute position;
For example:
var element = document.getElementById("label");
function handleFocus() {
element.classList.add("active");
}
function handleBlur() {
var myInput = document.getElementById("input");
if (!myInput.value) {
element.classList.remove("active");
}
}
.wrapper {
position: relative;
}
label {
position: absolute;
display: flex;
align-items: center;
height: 50px;
left: 10px;
}
.active {
height: 20px;
}
input {
padding: 5px;
widt: 100px;
height: 40px;
border: 2px solid purple;
border-radius: 4px;
}
<div class='wrapper'>
<label id='label'>blabla</label>
<input id='input'
onFocus="handleFocus();"
onBlur="handleBlur();"
/>
</div>
Related
I want to put icon inside the input tag but its always in the bottom of input. i used bootstrap actually but for this i used custom style
here's the html:
<div class="form-group">
<label for="password" class="text-secondary">Password</label>
<div class="input-group">
<input id="password" type="password" class="form-login #error('password') is-invalid #enderror" name="password" required autocomplete="current-password">
<div class="input-group-append">
<span class="input-group-text" onclick="password_show_hide();">
<i class="fas fa-eye" id="show_eye"></i>
<i class="fas fa-eye-slash d-none" id="hide_eye"></i>
</span>
</div>
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
here's the css:
.form-login{
display: block;
width:100%;
font-size: 1rem;
font-weight: 400;
line-height:1.5;
border-color: #009DA9 !important;
border-style: solid !important;
border-width: 0 0 1px 0 !important;
padding: 0px !important;
color:black;
height: auto;
border-radius: 0;
background-color: #fff;
background-clip: padding-box;
}
.form-login:focus{
color: #495057;
background-color: #fff;
border-color: #fff;
outline: 0;
box-shadow: none;
}
what it's look like right now:
what i want to look like:
Well you can use position absolute to position the icon over the input.
You might need to change the top value a little bit and the padding-right value. Check the comment inside the snippet below
.input-group {
position:relative;
display:inline-block;
}
.input-group-text {
position: absolute;
right:0;
top: 0;
}
input {
padding-right: 20px; /* = icon width if you don't want the password to go under the icon */
}
<div class="input-group">
<input id="password" type="password" class="form-login" />
<div class="input-group-append">
<span class="input-group-text">
<i class="fas fa-eye" id="show_eye">icon</i>
</span>
</div>
</div>
You can use position absolute to position the icon over the input field. Check to code I posted below:
.form-group {
width: 50%;
position: relative;
}
.form-group i {
position: absolute;
right: 0px;
}
.icon {
padding: 10px 0px;
color: grey;
min-width: 5px;
text-align: center;
}
.input-field {
width: 100%;
padding: 10px;
border-radius: 10px;
border-color: solid lightgray;
}
<div class="form-group">
<label for="passowrd">Password</label>
<div class="input-set">
<i class="fas fa-lock icon">icon</i>
<input id="password" name="password" class="input-field" type="text" placeholder="password" />
</div>
</div>
<div class="input-fields">
<div class="new">
<div class="first-container">
<form id="new-form" method="POST">
<div class="label">
<span class="fas fa-envelope icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div class="label">
<span class="far fa-id-card icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div class="label">
<span class="fas fa-user-tag icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div>
</div>
</div>
</div>
<div>
<span class="divide">or</span>
</div>
<div class="login-field">
<div class="second-container">
<div class="label">
<span class="far fa-id-card icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div class="label">
<span class="fas fa-key icon"></span>
<input type="email" name="email-address" class="form-input" placeholder=" ">
</div>
<div>
</div>
</div>
.fa-arrows-alt-h {
font-size: 30px;
color: #bbb;
}
.input-fields {
display: flex;
background: #F7F9F6;
}
.new {
width: 50%;
float: right;
border-right: 1px dashed #e9e9e9;
}
.form-input {
padding-left: 3.575rem;
height: calc(2.25rem + 2px);
font-size: 1.5rem;
}
.first-container {
display: inline-block;
float: right;
padding-right: 30px;
}
.second-container {
display: inline-block;
padding-left: 30px;
}
.divide {
position: absolute;
left: 0;
right: 0;
margin-left:auto;
margin-right:auto;
top: 20%;
}
I would like to align text, "or" in the middle of the vertical line.
I used left: 50% or 49%, however, it's broken when I shrink the window size for response test.
I couldn't use 'left:0; right: 0; because I did not know the width of text("or")
How can I align the word "or" in the middle of the vertical line?
Can anyone help, please?
Many thanks! :)
To your absolutely positioned span add these styles:
.divide{
left: 50%;
transform: translate(-50%);
}
It works see the codepen here: https://codepen.io/arnavozil/pen/mdVyWGr
The problem you had is that u're using flexbox and at the same time you're giving the containers specific width , instead you can use justify-content : center
.fa-arrows-alt-h {
font-size: 30px;
color: #bbb;
}
.input-fields {
justify-content: center;
display: flex;
display: flex;
background: #F7F9F6;
}
.new {
/* width: 50%; */
/* float: right; */
border-right: 1px dashed #e9e9e9;
}
.form-input {
padding-left: 3.575rem;
height: calc(2.25rem + 2px);
font-size: 1.5rem;
}
.first-container {
/* display: inline-block; */
/* float: right; */
padding-right: 30px;
}
.second-container {
/* display: inline-block; */
padding-left: 30px;
}
.divide {
/* position: absolute; */
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
/* top: 20%; */
} ```
I have a div named main-filter and within the div, I have two div. Now, I want to create a form with button, labels and input and I want to put two div inside the form and it should look like the below down screenshot. I have the HTML and CSS code but it is not working and couldn't figure out how to do it with CSS grid. I need to make it responsive as well!. I am totally new at CSS grid and any help would much be appreciated. Thank you.
.main-filter {
display: flex;
margin: 0px;
padding: 20px;
height: 90px;
background-color: #eff0f2;
color: #287993;
margin-bottom: 3rem;
}
.main-header__left {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 0.3em 0.6em;
grid-auto-flow: dense;
align-items: center;
float: left;
margin-left: 250px;
margin-right: 200px;
}
.main-header__right {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 0.3em 0.6em;
grid-auto-flow: dense;
align-items: center;
float: right;
}
.filter-button1 {
background: #38acd2;
color: #FFFFFF;
max-width: 380px;
min-width: 370px;
min-height: 35px;
font-weight: bold;
}
input,
button {
grid-column: 2 / 4;
width: auto;
margin: 0;
}
input {
width: 370px;
height: 30px;
border: 1px solid #38acd2;
}
<div className="main-filter">
<form onSubmit={this.addItem}>
<div className="main-header__left">
<label className="start-timestamp">Start Timestamp: </label>
<input type="text" ref={(input4)=> this.input4 = input4} className="input-item" id="addInput3" placeholder="Ex. 2019-1-12" />
<label className="source-ip-address">Source IP Address: </label>
<input type="text" name="source" ref={(input1)=> this.input1 = input1} className="input-item" id="addInput3" placeholder="127.0.0.1 " />
<label className="service">Service Name: </label>
<input type="text" name="service" ref={(input3)=> this.input3 = input3} className="input-item" id="addInput3" placeholder="Ex. Facebook or Whatsapp *" required />
</div>
<div className="main-header__right">
<label className="end-timestamp">End Timestamp: </label>
<input type="text" ref={(input5)=> this.input5 = input5} className="input-item" id="addInput3" placeholder="Ex. 2019-1-12" />
<label className="destinatin-ip-ddress">Destination IP Address:
</label>
<input type="text" name="destination" ref={(input2)=> this.input2 = input2} className="input-item" id="addInput3" placeholder="127.0.0.1 " />
<button type="submit" className="filter-button1">Apply
Filters</button>
</div>
</form>
</div>
css grid form Image screenshot,
Try using below code, I have modified HTML and CSS code, I hope this might help you to achieve expected result.
.main-filter {
/* margin: 0px; */
/* padding: 20px; */
height: 90px;
background-color: #eff0f2;
color: #287993;
}
form {
display: grid;
grid-template-columns: auto auto;
grid-gap: 15px;
}
.main-header__left>div,
.main-header__right>div {
display: flex;
}
.main-header__left>div>label,
.main-header__right>div>label {
width: 40%;
}
#media only screen and (max-width: 500px) {
/* .main-header__left {
grid-area: 2 / span 1;
grid-gap: 0;
} */
.main-header__right {
grid-area: 2 / span 1;
grid-gap: 0;
}
}
.filter-button1 {
background: #38acd2;
color: #FFFFFF;
min-height: 35px;
font-weight: bold;
border: none;
margin-top: 18px;
width: 100%;
}
input {
width: 100%;
height: 30px;
border: 1px solid #38acd2;
}
<div className="main-filter">
<form onSubmit={this.addItem}>
<div class="main-header__left">
<div>
<label class="start-timestamp">Start Timestamp: </label>
<input type="text" />
</div>
<div>
<label className="source-ip-address">Source IP Address: </label>
<input type="text" name="source" />
</div>
<div>
<label className="service">Service Name: </label>
<input type="text" name="service" />
</div>
</div>
<div class="main-header__right">
<div>
<label className="end-timestamp">End Timestamp: </label>
<input type="text" />
</div>
<div>
<label className="destinatin-ip-ddress">Destination IP Address:</label>
<input type="text" name="destination" />
</div>
<div>
<label></label>
<button type="submit" class="filter-button1">Apply Filters</button>
</div>
</div>
</form>
</div>
I'm implementing some custom styles for radio buttons and am having problems trying to perfectly center the checked buttons. When I paste the exact same code into JS Fiddle, things work perfectly. Yet in my web app, they are each off centered (in their own way) like the image below, despite having the same classnames, positioning, etc:
Image link: Off-centered checked radio buttons
HTML:
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check1"
>
<span class="radio-styled checked"></span>
<span class="label-text">Australia</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check2"
>
<span class="radio-styled checked"></span>
<span class="label-text">Belgium</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check3"
>
<span class="radio-styled checked"></span>
<span class="label-text">United Kingdom</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="some-other-element">
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check3"
>
<span class="radio-styled checked"></span>
<span class="label-text">New Zealand</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check3"
>
<span class="radio-styled checked"></span>
<span class="label-text">Canada</span>
</label>
<div class="RadioStyled">
</div>
</div>
</div>
CSS / SCSS:
.RadioStyled {
display: inline-block;
padding-right: 25px;
label.control-label {
cursor: pointer;
display: block;
line-height: 24px;
.label-text {
position: relative;
font-size: 14px;
color: black;
padding-left: 6px;
vertical-align: middle;
}
input[type="checkbox"], input[type="radio"] {
display: none;
}
.radio-styled {
border-radius: 50%;
border: 1px solid grey;
box-sizing: border-box;
display: inline-block;
height: 20px;
vertical-align: middle;
width: 20px;
}
.radio-styled.checked {
border: 1px solid grey;
background-color: green;
border-radius: 50%;
box-sizing: border-box;
display: inline-block;
width: 20px;
height: 20px;
vertical-align: middle;
}
.radio-styled.checked::before {
background-color: white;
border-radius: 50%;
box-sizing: border-box;
content: '';
display: inline-block;
height: 20px;
width: 20px;
// margin: -1px -1px;
transform: scale(0.5);
position: relative;
top: -1px;
right: 1px;
}
}
}
.some-other-element {
padding-left: 250px;
width: 400px;
}
Codepen here
Any idea what's happening here that makes each checked radio button seem to have a different position? Thanks!
I am trying to get a few images in a table looking alright but there is an empty input on the 3rd row and 1st column. Also the input image types look slightly bigger?
Edit: I forgot to mention this has also has to work for IE7 and up.
fiddle:
http://jsfiddle.net/486EX/
style
input {
border: 1px solid black;
}
.emptyicon {
width: 37px;
height: 37px;
float: left;
font-size: 8px;
border: 1px solid grey;
}
.sizewidth {
width: 19px;
height: 10px;
padding: 5px 3px 8px 3px;
margin: 2px;
}
.showborder {
border: 2px solid red;
}
#product {
border: 1px solid #c1c1c1;
}
.sizebtn {
margin: 2px;
height: 31px;
width: 37px;
}
.icons {
width: 213px;
float: left;
padding: 2px;
}
.icons div {
padding: 2px;
float: left;
}
.icons input {
padding: 0;
cursor: pointer;
text-align: center;
background: #FFF;
color: #000;
display: block;
height: 37px;
width: 37px;
line-height: 37px;
font-size: .6em;
overflow: hidden;
}
.sizes {
float: left;
width: 213px;
}
.sizes div {
padding: 2px 0 0 2px;
float: left;
}
.sizes input {
padding: 0;
cursor: pointer;
text-align: center;
background: #FFF;
color: #000;
display: block;
height: 30px;
width: 30px;
font-size: 1.2em;
}
html:
<div id="product">
<table>
<tbody>
<tr>
<td>
<div id="icons_7934" class="icons">
<div>
<input id="imgcolor_7934_Amethyst" text="Amethyst" class="emptyicon showborder" type="button"
value="Amethyst">
</div>
<div>
<input id="imgcolor_7934_Aquamarine" text="Aquamarine" class="emptyicon " type="button"
value="Aquamarine">
</div>
<div>
<input id="imgcolor_7934_Baby_Pink" text="Baby Pink" class="emptyicon " type="button"
value="Baby Pink">
</div>
<div>
<input id="imgcolor_7934_Biscuit" text="Biscuit" class="emptyicon " type="button"
value="Biscuit">
</div>
<div>
<input id="imgcolor_7934_Bisque" text="Bisque" class="emptyicon " type="button" value="Bisque">
</div>
<div>
<input id="imgcolor_7934_Black" src="Images/black.jpg" class="emptyicon " type="image"
value="Black">
</div>
<div>
<input id="imgcolor_7934_Burnt_Orange" text="BurntOrange" class="emptyicon " type="button"
value="BurntOrange">
</div>
<div>
<input id="imgcolor_7934_Candy" text="Candy" class="emptyicon " type="button" value="Candy">
</div>
<div>
<input id="imgcolor_7934_Cherry" text="Cherry" class="emptyicon " type="button" value="Cherry">
</div>
<div>
<input id="imgcolor_7934_Deep_Lilac" text="DeepLilac" class="emptyicon " type="button"
value="DeepLilac">
</div>
<div>
<input id="imgcolor_7934_Dusty_Rose" text="DustyRose" class="emptyicon " type="button"
value="DustyRose">
</div>
<div>
<input id="imgcolor_7934_Iceblue" text="Iceblue" class="emptyicon " type="button"
value="Iceblue">
</div>
<div>
<input id="imgcolor_7934_Lime" text="Lime" class="emptyicon " type="button" value="Lime">
</div>
<div>
<input id="imgcolor_7934_Magenta" text="Magenta" class="emptyicon " type="button"
value="Magenta">
</div>
<div>
<input id="imgcolor_7934_Navy" text="Navy" class="emptyicon " type="button" value="Navy">
</div>
<div>
<input id="imgcolor_7934_Peacock" text="Peacock" class="emptyicon " type="button"
value="Peacock">
</div>
<div>
<input id="imgcolor_7934_Royal_Blue" text="RoyalBlue" class="emptyicon " type="button"
value="RoyalBlue">
</div>
<div>
<input id="imgcolor_7934_Teal" text="Teal" class="emptyicon " type="button" value="Teal">
</div>
<div>
<input id="imgcolor_7934_White" src="Images\White.jpg" class="emptyicon " type="image"
value="White">
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<script>
$("[id^='imgcolor_7934']").live("click", function () {
$("[id^='imgcolor_7934']").removeClass('showborder');
$(this).addClass("showborder");
});
</script>
I think your borders are throwing off the alignment. To correct, try using box-sizing:border-box;
Like so:
Working Example
.emptyicon {
width: 37px;
height: 37px;
float: left;
font-size: 8px;
border: 1px solid grey;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
box-sizing documentation -MDN
If you need to support ancient IE you can use this instead:
Working Example 2
#imgcolor_7934_White, #imgcolor_7934_Black{
height:35px;
width:35px;
}
#imgcolor_7934_White.showborder, #imgcolor_7934_Black.showborder{
height:33px;
width:33px;
}