I have this long form for users with several html elements.
I used Materialize framework for it.
Here's the collpsible link.
The form is getting too long.
How to remove some space between elements and make it all narrower so I don't need to scroll down?
I didn't find it in framework options.
Here's the html code for the elements:
<div class="container">
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">add</i>
<input id="stat" type="text" class="validate">
<label for="stat">Добавить новую статистику</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<i class="material-icons prefix">assignment</i>
<input id="des" type="text" class="validate">
<label for="des">Добавить описание статистики</label>
</div>
</div>
<div class="row">
<div class="input-field col s1">
<i class="material-icons prefix">trending_down</i>
</div>
<div class="input-field col s8">
<h6>
Добавить минимальное значение
</h6>
</div>
<div class="input-field col s3">
<input id="des" type="text" class="validate">
</div>
</div>
<div class="row">
<div class="input-field col s1">
<i class="material-icons prefix">trending_up</i>
</div>
<div class="input-field col s8">
<h6>
Добавить максимальное значение
</h6>
</div>
<div class="input-field col s3">
<input id="des" type="text" class="validate">
</div>
</div>
<a class="waves-effect waves-light btn-small #039be5 light-blue darken-1" id="btn"><i class="material-icons right">send</i>Добавить</a>
<p> </p>
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">filter_drama</i>Добавить данные в статистики:</div>
<div class="collapsible-body">
<span>
<div class="row">
<div class="input-field col s1">
<p>
<i class="material-icons prefix">wb_sunny</i>
</p>
</div>
<div class="input-field col s7">
<select class="icons browser-default" id="weeksSel2" onChange ="getWeekText2();">
<option value="" disabled selected>Выберите неделю</option>
</select>
</div>
</div>
</span>
</div>
</li>
</ul>
</div>
<!-- end of container -->
I'm not very much hands on the materializecss, but I found the same problem somebody is facing, have a look this might can help you out.
As per below link you need to consolidate all the col element in the single row.
Spacing Between Rows with Materialize CSS
You might want to remove margin-bottom from .row.
<div class="row">
Add another class to your div with class row, say custom-row
<div class="row custom-row">
and add style:
.custom-row {
margin-bottom: 0 !important; /*this will override margin-bottom:10px from '.row'
}
This will keep all the styles from .row but override the margin-bottom
Hope it helps!
Related
My concern is my middle col-md-4, there is an annoying margin in the bottom. I tried disabling some CSS in the inspect element but it still stays. How can I center my search bar?
Here is my bootstrap:
<div class="container mb-3 mt-3">
<div class="row align-self-center">
<div class="col-md-4">
<img src="img/logo_header.png" class="img-fluid" width="200">
</div>
<div class="col-md-4">
<form action="cards/search.php" method="POST">
<div class="input-group">
<input type="text" name="text-search" id="searchBox" class="form-control search-bar" aria-label="Default" aria-describedby="inputGroup-sizing-default" placeholder="Search Coupons" required>
<div class="input-group-prepend">
<button type="submit" name="submit-search" class="input-group-text bg-blue"> <i class="fas fa-search"></i> </button>
</div>
</div>
<div id="response" class="scrollbar-design search-content"></div>
</form>
</div>
<div class="col-md-4">
<img src="img/logo_header.png" class="img-fluid" width="200">
</div>
</div>
</div>
UPDATE:
padding 0px does not seem to work
just add my-auto since it's bootstrap
<div class="col-md-4 mx-auto text-center my-auto">
</div>
I have a contact form (a bunch of input/span elements) nested in a Boostrap col. As the browser shrinks, the input fields shrink to an undesirable size.
I have tried adding various col-breakpoints, which sort-of works, but it looks funky and still shrinks too much until it hits the breakpoint. I have also looked for a way to specify a min-width of sorts, but haven't had luck with that either.
<!-- Custom CSS -->
.input-group-text {
width: 40px;
}
.input-group-text span {
margin: 0 auto;
}
.body-main-bg {
background-color: #eeeeee;
}
<!-- Contact Form -->
<div class="container-fluid">
<div class="row body-main-bg justify-content-center">
<div class="col-4 my-3 text-center">
<h4>Contact Us</h4>
</div>
</div>
<form id="contact-form" method="" action="">
<div class="row body-main-bg justify-content-center">
<div class="col-4 mb-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-user"></span>
</span>
</div>
<input type="text" class="form-control" placeholder="Name">
</div>
</div>
</div>
<div class="row body-main-bg justify-content-center">
<div class="col-4 mb-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-envelope"></span>
</span>
</div>
<input type="text" class="form-control" placeholder="Email">
</div>
</div>
</div>
<div class="row body-main-bg justify-content-center">
<div class="col-4 mb-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-ellipsis-v"></span>
</span>
</div>
<input type="text" class="form-control" placeholder="Subject">
</div>
</div>
</div>
<div class="row body-main-bg justify-content-center">
<div class="col-4 mb-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fa fa-pencil"></span>
</span>
</div>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="Message"></textarea>
</div>
</div>
</div>
<div class="row body-main-bg justify-content-center">
<div class="col-4 mb-3">
<button class="btn btn-primary btn-block" type="submit">Submit</button>
</div>
</div>
</form>
</div>
If you change col-4 to col-lg-4 or col-md-4 you will have the desired layout.
The issue is that with col-4 you are essentially saying "stay this width on all devices". When col-lg-4 or col-md-4 are responsive and set divs to be 100% on large/medium devices and down.
See bootstraps grid options here: https://getbootstrap.com/docs/4.3/layout/grid/
I embedded a radio button in two cards. To group them together I nested the two cards inside a btn-group.
This works very well but the layout crashes on small display sizes.
When it shrinks down to xs the two columns should fill one whole row but it doesn't happen. The second card vanishes you can't scroll to it.
I tried a lot but I can't make it work on small screens.
When I omit the radio group wrapper the layout works but obviously my radio buttons don't.
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<!-- Grid row -->
<div class="row">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<div class="col-12 col-lg-6 col-md-6">
<div class="card">
<div class="card-body">
<h5 class="mb-4">Card Title 1</h5>
<div class="d-flex justify-content-center">
<div class="card-circle d-flex justify-content-center align-items-center">
<i class="fa fa-users light-blue-text"></i>
</div>
</div>
<p class="grey-text">Paragraph 1.</p>
<label id="label1" class="btn btn-secondary active" for="input1">
Radio1
<input type="radio" id="input1"
name="name1"
value="val1" checked>
</label>
</div>
</div>
</div>
<div class="col-12 col-lg-6 col-md-6 mb-lg-0 mb-4">
<div class="card">
<div class="card-body">
<h5 class="mb-4">Card title 2</h5>
<div class="d-flex justify-content-center">
<div class="card-circle d-flex justify-content-center align-items-center">
<i class="fa fa-user light-blue-text"></i>
</div>
</div>
<p class="grey-text">Card paragraph 2.</p>
<label id="label2" class="btn btn-secondary" for="radio2">
<input type="radio" id="radio2"
name="name1"
value="val2">
Radio 2</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Not working but not layout breaking:
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<!-- Grid row -->
<div class="row">
<div class="col-12 col-lg-6 col-md-6">
<div class="card">
<div class="card-body">
<h5 class="mb-4">Card Title 1</h5>
<div class="d-flex justify-content-center">
<div class="card-circle d-flex justify-content-center align-items-center">
<i class="fa fa-users light-blue-text"></i>
</div>
</div>
<p class="grey-text">Paragraph 1.</p>
<label id="label1" class="btn btn-secondary active" for="newSurgery">
Radio1
<input type="radio" id="input1"
name="name2"
value="val1" checked>
</label>
</div>
</div>
</div>
<div class="col-12 col-lg-6 col-md-6 mb-lg-0 mb-4">
<div class="card">
<div class="card-body">
<h5 class="mb-4">Card title 2</h5>
<div class="d-flex justify-content-center">
<div class="card-circle d-flex justify-content-center align-items-center">
<i class="fa fa-user light-blue-text"></i>
</div>
</div>
<p class="grey-text">Card paragraph 2.</p>
<label id="label2" class="btn btn-secondary" for="radio2">
<input type="radio" id="radio2"
name="name2"
value="val2">
Radio 2</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Your second snippet works fine, you just got the for attribute wrong on the 1st label, so you need to click the actual radio button to see it working.
If you change the for attribute, from the non existent newSurgery to input1, it will work as expected:
<label id="label1" class="btn btn-secondary active" for="input1">
<!-- not for="newSurgery"-->
Radio1
<input type="radio" id="input1" name="name2" value="val1" checked>
</label>
I don't think radio buttons have anything to do with their surrounding HTML elements. You just need to have the same name for them:
<input type="radio" id="input1" name="HAVE_TO_BE_THE_SAME" value="val1" checked />
<input type="radio" id="input2" name="HAVE_TO_BE_THE_SAME" value="val2" />
The name is what groups the radio buttons together. You can have different id and value. The label for attribute points to the id of the element, not the name.
And you have too many unnecessary row and column markups. Try to read the bootstrap documentation one more time.
<div class="container-fluid">
<div class="row">
<!--
By default, the div is displayed as block so you don't need
`col-12` unless they're not displayed as block and you force them
to.
-->
<div class="col-md-6">
<div class="card"> ... </div>
</div>
<div class="col-md-6">
<div class="card"> ... </div>
</div>
</div>
</div>
fiddle: http://jsfiddle.net/aq9Laaew/250477/
I have this html using materialize css
<!-- Sign Up Card row -->
<div class="row">
<div class="col s12 m12">
<div class="card">
<div class="card-content">
<span class="card-title"><h3>Sign up to find out more.</h3></span>
<form class="container">
<div class="input-field col m6">
<input id="email" type="email" class="validate">
<label for="email">Email</label>
</div>
<div class="input-field col m6">
<button class="btn waves-effect waves-light" type="submit" name="action">
Submit <i class="material-icons right">send</i>
</button>
</div>
</form>
</div>
</div>
</div>
</div><!-- End of Sign Up Card row -->
Which is giving me this result
When I remove the col m6 classes from the input-field divs it shows them correctly within the card but stacked one on top of the other.
How do I achieve having both divs inside the card and positioned on the same row?
My UI Design of desired composition of card
Update
Working JSFiddle
Note: Modifying the css itself is undesired and a last resort. The prime solution should use only materialize css for which I think I should have been more specific.
use <div class="row"></div> to wrap around the div.col tags
jsfiddle
<!-- Sign Up Card row -->
<div class="row">
<div class="col s12 m12">
<div class="card">
<div class="card-content">
<span class="card-title"><h3>Sign up to find out more about Two Lanterns.</h3></span>
<form class="container">
<div class = "row">
<div class="input-field col m6">
<input id="email" type="email" class="validate">
<label for="email">Email</label>
</div>
<div class="input-field col m6">
<button class="btn waves-effect waves-light" type="submit" name="action">
Submit <i class="material-icons right">send</i>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div><!-- End of Sign Up Card row -->
Try this way, replace container block with following code.
<form class="container" style="display: flex">
<div class="input-field ">
<input id="email" type="email" class="validate">
<label for="email">Email</label>
</div>
<div class="input-field " style="padding-left:16px">
<button class="btn waves-effect waves-light" type="submit" name="action">
Submit <i class="material-icons right">send</i>
</button>
</div>
</form>
After getting some help with alignment of my controls, I'm now struggling to fully understand, exploit and adopt that solution.
The current state of affairs can be played with here and the code is below:
<div class="row">
<div class="col-lg-8">
<div class="form-inline col-lg-4">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-key fa-fw"></span></div>
<input id="oldpswd" name="oldpswd" placeholder="Altes Passwort" type="password" class="form-control">
</div>
</div>
</div>
<span id="oldpswd_errmsg" class="bg-danger col-lg-4">xxxx</span>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="form-inline col-lg-4">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-key fa-fw"></span></div>
<input id="oldpswd" name="newpswd" placeholder="Neues Passwort" type="password" class="form-control">
</div>
</div>
</div>
<span id="newpswd_errmsg" class="bg-danger col-lg-4">xxxx</span>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="form-inline col-lg-4">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-key fa-fw"></span></div>
<input id="reppswd" name="reppswd" placeholder="Passwort wiederholen" type="password" class="form-control">
</div>
</div>
</div>
<span id="reppswd_errmsg" class="bg-danger col-lg-4">xxxx</span>
</div>
</div>
Question: within the row there is a col-lg-8 that contains two col-lg-4 divs. As I understood the doc, the input-controls are supposed to take up the entire width of their containers, yet the form-group inside the col-lg-4 is significantly smaller than its container.
How can this layout be fixed so that the divs with designated col-lg- classes use the available space?
Updated
Addedd css to expand the form controls to expand with divs.
Is this what you want? http://www.bootply.com/y2K2OY8H1H
You had a row, with a column of 8, with two columns of 4 inside that. So the col-8 fills 8 of the 12 main columns. Then the 2 col-4 inside of that only fill 8 of the 12 inside that col-8. So each time you nest the col's you create nested columns. It is a little confusing, but makes sense.
NEW CSS:
.form-group {
width:100%;
}
.input-group {
width:100%;
}
-
<div class="row">
<div class="col-md-2">
<div class="form-inline">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-key fa-fw"></span></div>
<input id="oldpswd" name="oldpswd" placeholder="Altes Passwort" type="password" class="form-control">
</div>
</div>
</div>
</div>
<span id="oldpswd_errmsg" class="bg-danger col-lg-3">xxxx</span>
</div>
<div class="row">
<div class="col-md-2">
<div class="form-inline">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-key fa-fw"></span></div>
<input id="oldpswd" name="newpswd" placeholder="Neues Passwort" type="password" class="form-control">
</div></div>
</div>
</div>
<span id="newpswd_errmsg" class="bg-danger col-lg-3">xxxx</span>
</div>
<div class="row">
<div class="col-md-2">
<div class="form-inline">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-key fa-fw"></span></div>
<input id="reppswd" name="reppswd" placeholder="Passwort wiederholen" type="password" class="form-control">
</div></div>
</div>
</div>
<span id="reppswd_errmsg" class="bg-danger col-lg-3">xxxx</span>
</div>