Material Vertical Divider isn't showing up - html

I made a really simple program because i wanted to try out the vertical divider provided by angular material but for some reason it's not showing up.
My code is:
<div>
<span>code</span>
</div>
<mat-divider [vertical]="true"></mat-divider>
<div>
<span>2</span>
</div>

Try adding a height to the vertical divider.
<mat-divider vertical style="height:100px"></mat-divider>
Stackblitz
https://stackblitz.com/edit/angular-wp9f4j?embed=1&file=app/divider-overview-example.html

Try adding following class to .css
.mat-divider-vertical{
height: 100%;
width: 0px !important;
position: inherit !important;
}
and set
style="position: relative;"
to outer element to make "100%" work.

I have used the below approach to get mat-divider vertical to work for my code.
<div class="row">
<div class="col-md-5">
<div class="row">
<div class="col-md-2 px-2">Search</div>
<div class="col-md-6">
<input id="search" class="form-control " placeholder="Search" name="search">
</div>
</div>
<div class="row">
<div class="col-md-2 px-2">Search</div>
<div class="col-md-6">
<input id="search" class="form-control " placeholder="Search" name="search">
</div>
</div>
<div class="row">
<div class="col-md-2 px-2">Search</div>
<div class="col-md-6">
<input id="search" class="form-control " placeholder="Search" name="search">
</div>
</div>
</div>
<mat-divider [vertical]="true" style="height: auto;"></mat-divider>
<div class="col-md-5">
<div class="row">
<div class="col-md-2 px-2">Search</div>
<div class="col-md-6">
<input id="search" class="form-control " placeholder="Search" name="search">
</div>
</div>
</div>
Along with
.mat-divider-vertical{
height: 100%;
width: 0px !important;
position: inherit !important;
}
screenshot of the output

Related

Centering own created div class responsive

I am trying to center my <div class="loginfeld"> but I cant get it to go center (in the middle), while staying responsive.
<html>
<body>
<div class ="loginfeld">
<div class="container">
<div class="col-lg-4"></div>
<div class="col-lg-4">
<div class="jumbotron">
<center><h1>Hallo!</h1></center>
<br>
<form action="login.php" method="POST">
<div class="form-group">
<input type="text" class="form-control" name="benutzername"
placeholder="Benutzernamen eingeben">
</div>
<div class="form-group">
<input type="text" class="form-control" name="passwort"
placeholder="Passwort eingeben">
</div>
<button type="text" class="btn
btn-primary form-control" name ="login">Login</button>
<center><p><?php echo $hinweis; ?></p></center>
</form>
</div>
</div>
<div class="col-lg-4"></div>
</div>
</div>
</body>
</html>
In my css-style file:
.loginfeld{
margin-top: 250px;
margin-left: 750px;
max-width: 1000px;
}
It does go in the middle of my screen, but it's not really resposive. I tried to use codes which were written in the forum to responsively center it, but it did not work out for me.
Thats how it looks now, after I used the code K_LUN wrote down. It is centerd, but now the login box is messed up.
Bootstrap provides more than enough classes to achieve what you need with minimal custom CSS.
I deleted the additional col-lg-4 that you had at the start and end of the container; also added a row div since you should have col-* classes inside a row only.
After that, you can just add justify-content-center to the row to center the element, as well as align-items-center along with a custom property height: 100vh so the row uses the full height of the viewport.
.full-scrn {
height: 100vh;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<body>
<div class="container">
<div class="row justify-content-center align-items-center full-scrn">
<div class="col-10 col-md-8 col-lg-4">
<div class="jumbotron">
<center>
<h1>Hallo!</h1>
</center>
<br>
<form action="login.php" method="POST">
<div class="form-group">
<input type="text" class="form-control" name="benutzername" placeholder="Benutzernamen eingeben">
</div>
<div class="form-group">
<input type="text" class="form-control" name="passwort" placeholder="Passwort eingeben">
</div>
<button type="text" class="btn
btn-primary form-control" name="login">Login</button>
<center>
<p>
<?php echo $hinweis; ?>
</p>
</center>
</form>
</div>
</div>
</div>
</div>
</body>
I don't know if you want it at the exact center of the screen(like from left,right,top,bottom) or just the horizontal center.
For the horizontal center, you can simply do-
.parent-element{
background: lightblue;
width: 300px;
height: 300
}
.centered-element{
margin: auto;
width: 200px;
height: 200px;
background: cyan;
text-align: center;
margin-top: 10px;
margin-bottom: 10px;
}
<div class="parent-element">
<div class="centered-element">
Sample Text
</div>
</div>
You can use grid offsets to keep a column centered:
<div class="container">
<div class="col-xs-12 col-xs-offset-0 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<div class="jumbotron">
<h1 class="text-center">Hallo!</h1>
<form action="login.php" method="POST">
<div class="form-group">
<input type="text" class="form-control" name="benutzername" placeholder="Benutzernamen eingeben">
</div>
<div class="form-group">
<input type="text" class="form-control" name="passwort" placeholder="Passwort eingeben">
</div>
<button type="text" class="btn
btn-primary form-control" name="login">Login</button>
<p class="text-center">
<?php echo $hinweis; ?>
</p>
</form>
</div>
</div>
</div>
Demo
Notice a few things:
Use text-center rather than additional markup for centering
Don't use line breaks for spacing. Use CSS (.jumbotron h1 {margin-bottom: 20px;})

How to add a button to my page (Laying out the button on HTML)

I would like to add a button to the right of the zip code without effecting the size of the field.
Any suggestions would be appreciated.
My original markup was (which is what picture matches):
<div class="col-md-6 col-md-offset-3 text-center" style="border:solid">
// All my fields...
</div>
I then tried:
<div class="col-md-3"></div>
<div class="col-md-6">
// All my fields using form-group
</div>
<div class="col-md-3">
<div class="form-group"></div>
<div class="form-group"></div>
<div class="form-group"></div>
<div class="form-group"></div>
<div class="form-group"></div>
<div class="form-group"></div>
<div class="form-group">
#(Html.Kendo().Button()
.Name("btnLookup")
.Content("Lookup")
)
</div>
</div>
However it placed the button to the top of the form.
Before I added the button the page looks like:
Have you tried adding them via display: absolute?
.form-group {
position: relative;
}
.lookup {
position: absolute;
top: 0;
right: -50px;
width: 40px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Name">
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Email">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Postal">
<button class="btn btn-primary lookup"><i class="glyphicon glyphicon-search"></i>
</button>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="City">
</div>
</div>
</div>
</div>

Bootstrap thumbnails overlapping other elements on smaller screens

I have created a large form using bootstrap. I didn't use the <form> element however, as I organised input fields in various <input> inside thematic Bootstrap panels.
One of these panels uses a thumbnail as an input button to submit a user photo.
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Biodata</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-2">
<div class="form-group">
<label for="personidphoto">ID Photo:</label>
<a class="thumbnail thumbnail-button" href="#">
<img src="blank_avatar.png" id="personidphoto">
</a>
</div>
</div>
<div class="col-sm-10">
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<label for="birthday">Birthdate:</label>
<input type="number" class="form-control" id="birthday" min="1" max="31" placeholder="DD">
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="birthmonth">&nbsp</label>
<input type="number" class="form-control" id="birthmonth" min="1" max="12" placeholder="MM">
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="birthyear">&nbsp</label>
<input type="number" class="form-control" id="birthyear" min="1900" max="2015" placeholder="YYYY">
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="gender">Gender:</label>
<input type="text" class="form-control" id="gender">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="medical">Notable medical condition(s):</label>
<input type="text" class="form-control" id="medical">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I've had to style the thumbnail to it to fit among from-groups.
a.thumbnail.thumbnail-button {
height: 108px;
width: 108px;
display: block;
margin-bottom: 7px;
}
Now the problem is: when re-sizing the screen, the thumbnail then overlaps with the other form-group elements.
What can I do to fix this?
You can use percentages instead of pixels for the image. Checkout this codepen.
CSS:
a.thumbnail.thumbnail-button {
width: 100%;
display: block;
margin-bottom: 7px;
}
Your fixed width breaks your lay-out. When your width is in percentages, your width will scale with the page which solves your problem.
You have set a fixed width and height to the .thumbnail-button. So you need to:
a.thumbnail.thumbnail-button {
margin: 0;
display: block;
margin-bottom: 7px;
}
And give the image, full width:
a.thumbnail.thumbnail-button img {
width: 100%;
}
And give the a.thumbnail.thumbnail-button, a grid class:
<a class="thumbnail thumbnail-button col-md-2">

Why isn't my CSS taking effect on a textarea?

I can't figure out why none of the CSS I am using is having an effect on a textarea. The textarea's id is "addquestion", which is what I'm using in my CSS, but to no avail. Inline CSS works, but not through my separate stylesheet. I can verify that the stylesheet is definitely linked correctly because there is another element that is working just fine, its just this textarea that isn't being affected.
#addquestion {
width: 20px;
height: 120px;
border: 3px solid #cccccc;
padding: 5px;
font-family: Tahoma, sans-serif;
background-image: url(bg.gif);
background-position: bottom right;
background-repeat: no-repeat;
}
<form>
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<textarea class="form-control" rows="3" id="addquestion" style="width:20px;" placeholder="Find this for me..."></textarea>
</div>
<div class="form-group">
<div class="input-group" id="addtags">
<input type="text" class="form-control" placeholder="Tags">
</div>
</div>
<div class="form-group">
<div class="input-group" id="addmoney">
<span class="input-group-addon">$</span>
<input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
</div>
</div>
</div>
<div class="col-md-6">
<input type="file" id="main_upload_file">
</div>
</div>
</div>
</div>
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<a class="btn btn-success" type="submit">Submit</a>
</div>
</div>
</div>
</div>
</form>
You could try changing #addquestion to textarea in your css file. Unless you have other textareas, of course.

How to add spacing between the words in a <p> tag and align them with text boxes in the next div

The following is the code for the form which I wrote:
<div class="container-fluid" id="unlabelled">
<p class="bg-primary">Items<span>Quantity</span><span>In Kit</span></p>
<form>
<div class="form-group col-lg-5">
<input type="text" class="form-control" id="unlabelled-items" placeholder="Enter code or description">
</div>
<div class="form-group col-md-2">
<input type="text" class="form-control" id="quantity" placeholder="Enter Quantity">
</div>
<div class="form-group">
<input type="checkbox" id="in-kit">
<button class="btn-primary" id="add-btn">Add</button>
</div>
</form>
</div>
I am using bootstrap here. And I have the top paragraph heading with a class="bg-primary" which gives a nice background for the heading. I have two text input fields, a checkbox and a button. I want to align the text in the above paragraph with these fields.
https://imgur.com/XinA1kT
I want the Items text to be aligned in center with the first text field, Quantity with the second text field and the In kit with the check box.
As you can see in my code, I added span tags around the text. I experimented with it by adding margin properties to these span tags, but it didn't work properly. I tried a bunch of it works okay but I atleast need 15 to 20 of them which even didn't solve my problem.
Is there any alternative for this? I could even try other alternatives for the p tag too.
Thank you.
This can at least get you started, it's just rows and columns and some minor CSS. The problem you'll have is on a mobile device, if you want this to remain completely horizontal it'll start to break down.
.well-md.well-head {
background: #3973a6;
border: none;
color: #fff;
font-size: 18px;
height: 60px;
text-align: center;
}
.checkbox {
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<form>
<div class="row well well-md well-head">
<div class="col-xs-4">
<p>Items</p>
</div>
<div class="col-xs-3">
<p>Quantity</p>
</div>
<div class="col-xs-3">
<p>In Kit</p>
</div>
</div>
<div class="row">
<div class="form-group col-xs-4">
<input type="text" class="form-control" id="unlabelled-items" name="unlabelled-items" placeholder="Enter code or description">
</div>
<div class="form-group col-xs-3">
<input type="text" class="form-control" id="quantity" name="quantity" placeholder="Enter Quantity">
</div>
<div class="form-group">
<div class="form-group col-xs-3">
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="in-kit" name="in-kit">
</div>
</div>
</div>
<div class="form-group col-xs-2">
<button class="btn btn-primary" id="add-btn">Add</button>
</div>
</div>
</div>
</form>
</div>
You need to put your text descriptors into columns that match with the columns for you inputs. Like this:
<div class="container-fluid" id="unlabelled">
<p class="bg-primary">
<div class="row">
<div class="form-group col-md-5"> Items</div>
<div class="form-group col-md-2">Quantity</div>
<div class="form-group col-md-2">In Kit</div>
</div>
</p>
<form>
<div class="form-group col-md-5">
<input type="text" class="form-control" id="unlabelled-items" placeholder="Enter code or description">
</div>
<div class="form-group col-md-2">
<input type="text" class="form-control" id="quantity" placeholder="Enter Quantity">
</div>
<div class="form-group">
<div class="form-group col-md-2">
<input type="checkbox" id="in-kit">
</div>
<div class="form-group col-md-2">
<button class="btn-primary" id="add-btn">Add</button>
</div>
</div>
</form>
</div>