I am designing my first program with flask/python and using Bootstrap 5 for the front end. I have a modal that has at least 6 form rows, what is the best practices way to line up the form entry boxes so it looks good? Do I put it into 2 columns then put each form line in a separate row? Is it correct to assume that the modal has its own column/row numbers that do not talk to the rest of the html, or is it somehow connected? Before I write/rewrite a bunch of tags and classes maybe someone could give me a brief guide/explanation. Thank you!
When you create a row with bootstrap, it take the original size of your div. Then all col-x will be a sub-division of this row (width)
what is the best practices way to line up the form entry boxes so it looks good?
It entirely depends on you. If you wish to have one label plus input per line(row) then you can do something like that:
<div class="row">
<div class="col-md-6">
<label for="input1">label1</label>
</div>
<div class="col-md-6">
<input type="text" id="input1">
</div>
</div>
<div class="row">
<div class="col-md-6">
<label for="input2">label2</label>
</div>
<div class="col-md-6">
<input type="text" id="input2">
</div>
</div>
Or
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-12">
<label for="input1">label1</label>
</div>
</div>
<div class="row">
<div class="col-12">
<label for="input2">label2</label>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-12">
<input type="text" id="input1">
</div>
</div>
<div class="row">
<div class="col-12">
<input type="text" id="input2">
</div>
</div>
</div>
</div>
Does the same result, but you will prefer to use the first solution
Do I put it into 2 columns then put each form line in a separate row?
This is correct
Is it correct to assume that the modal has its own column/row numbers that do not talk to the rest of the html, or is it somehow connected?
This is also correct, the row in you modal is not connected to the rest of the HTML
I guess you have already seen this page, but in case, here is the documentation: https://getbootstrap.com/docs/5.0/layout/grid/
Related
I have a form with multiple inputs.
All of those inputs are Dropdowns, Checkboxes, short Texts, etc. Except one which can be come quite large (textarea). I want all the smaller Inputs on the left side of the Page and the textarea on the right side of the Page.
The Textarea is supposed to have the same height as all the elements on the right side and take roughly half of the Pages width.
My problem is now that I am unable to properly add the Textarea to the right Side. When I use "float:right" then it either has an huge gap between the smaller Elements and itself, or it is small and when I make it bigger then the small Elements become smaller. Or it has the correct size, but then it only has one Element on the left side and every other Element comes after the Textarea has ended.
<form method="post">
<input asp-for="ID" type="hidden" />
<div asp-validation-summary="All" class="text-danger"></div>
<div class="row " >
<div class="form-group col-md-6">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="form-group col-md-5">
<label asp-for="Comment" class="control-label"></label>
<textarea asp-for="Comment" rows="14" class="form-control" oninput='this.style.height = "";this.style.height = this.scrollHeight + 3 + "px"' height:"100vh">
</textarea>
<span asp-validation-for="Comment" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
.....
</div>
<div class="form-group col-md-3">
....
</div>
</div>
<div class="row">
#if (Model.Valid is not null)
{
<div class="form-group col-md-3">
....
</div>
}
<div class="form-group col-md-3">
....
</div>
</div>
<div class="row">
......
<hr />
.....
So, all the smaller Elements are inside the "form-group", which are mostly inside "row". And on the right side I now want the Comment TextArea.
I would prefer a plain Bootstrap Solution (especially since everything else is already working in Bootstrap), but I am open to everything.
I have just started learning Bootstrap and am trying to implement it in a web page. But I am having trouble in preventing the bootstrap class divs from overlapping each other. On full screen, the web page looks like:
On reducing the width of the window by some amount, it becomes:
And making window almost as small as mobile screen I get this:
My html code for this is:
<body>
<div id="point" class="row container-fluid">
<div id="point_display" class="col-md-10">
</div>
<div id="point_info" class="row col-md-2">
<div class="col-md-8">
<h5>Current point position:</h5>
<p></p>
</div>
<div class="col-md-8">
<input type="checkbox" id="coordinate_transform" onclick="transformCoordinate(this.checked)"><span>Transform co-ordinate system</span></input>
</div>
<div class="col-md-8">
<h5>Transformation matrix:</h5>
<div id="transformMatrix">
</div>
</div>
</div>
</div>
<div id="control" class="row container-fluid">
<div id="slider" class="col-md-2">
<input type="range" value="0" min="0" max="100" oninput="changePosition(this.value)" onchange="changePosition(this.value)" />
</div>
<!--div id="coordinate" -->
<div class="col-md-3"><span>X: </span><input id="newX" type="number" step="0.0001" value=1 00></div>
<div class="col-md-3"><span>Y: </span><input id="newY" type="number" step="0.0001" value=1 00></div>
<div class="col-md-3"><span>Z: </span><input id="newZ" type="number" step="0.0001" value=- 300></div>
<!--/div-->
<div class="col-md-3"><button id="change_destination" onclick="setNewDestination()">Set New Destination</button></div>
<div class="col-md-3"><button id="reset_camera" onclick="resetCamera()">Reset Camera</button></div>
</div>
<script src="js/main_script.js"></script>
</body>
The black part of the page with axes and stuff is dynamically added to the div with id= point_display inside div point and the matrix is also dynamically added in the div with id = `transformMatrix"
Please help me figure out how to prevent the overlapping of the elements so that on reducing width, they just stack one below other.
I'm trying to make a page via Foundation that lets users post articles, however, I'm having a problem. Here's what the page looks like: http://jsfiddle.net/60a2g5fn/ (be sure to expand the viewing window, or it will assume that you're on a mobile browser)
I'm required to post code after a JSFiddle link, so here's what the associated inputs/rows looks like.
<div class="row">
<div class="large-6 columns">
<label>Title
<input type="text" name="HK_NEWS_TITLE">
</label>
</div>
<div class="large-6 columns">
<label>Topstory Image</label>
<select name="HK_NEWS_IMAGE">
</select>
</div>
</div>
<div class="row">
<div class="large-3 columns">
<label>Slug
<input type="text" name="HK_NEWS_SLUG">
</label>
</div>
<div class="large-6 columns">
<label>Topstory Image Preview</label>
<img src="http://www.pattiknows.com/wp-content/uploads/2014/08/love-man-woman-silhouette-sun-sunset-sea-lake-beach-300x187.jpg">
</div>
</div>
The dropdown is where they can choose the images that uses PHP and Javascript to choose and append the image from a directory. Once they pick the image, it is appended under Topstory Image Preview, but it breaks the row and makes the slug have empty space below it.
Here's an image of the before, so you can compare. I want the image to be under Topstory Image Preview, but I don't want it to create unnecessary space below the Slug input bar.
Is there any way that I can do this? I've tried multiple things (aligning the image right out of the row, doesn't work. using css to make it the background-image, doesn't work). Any help would be appreciated.
Here's a way using which you can achieve what you're trying to do. For the mobile layout, I believe it appears fine as it is but for the desktop layout, you can set the position of the image to absolute using #media-queries so that there's no empty white space to the left side of the image.
Here's a demo (view as full page):
#media (min-width: 1025px) {
img#ts-preview {
position: absolute;
}
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/foundation/5.0.2/css/foundation.min.css" rel="stylesheet" />
<link href="http://cdnjs.cloudflare.com/ajax/libs/foundation/5.0.2/css/normalize.min.css" rel="stylesheet" />
<form method="POST" action="news">
<div class="row">
<div class="large-6 columns">
<label>Title
<input type="text" name="HK_NEWS_TITLE">
</label>
</div>
<div class="large-6 columns">
<label>Topstory Image</label>
<select name="HK_NEWS_IMAGE"></select>
</div>
</div>
<div class="row">
<div class="large-3 columns">
<label>Slug
<input type="text" name="HK_NEWS_SLUG">
</label>
</div>
<div class="large-6 columns">
<label>Topstory Image Preview</label>
<img id="ts-preview" style="padding-bottom:20px;" src="http://www.pattiknows.com/wp-content/uploads/2014/08/love-man-woman-silhouette-sun-sunset-sea-lake-beach-300x187.jpg">
</div>
</div>
<div class="row">
<div class="large-6 columns">
<label>Short Story
<input type="text" name="HK_NEWS_SHORT">
</label>
</div>
</div>
<div class="row">
<div class="large-6 columns">
<label>News Content</label>
<textarea name="HK_NEWS_CONTENT"></textarea>
</div>
</div>
</form>
I am using the jquery tab control. I have a form in each of them and I want to submit each form independently. I have been googling and reading about forms and submit but the only way I have found so far is by using jquery. I would prefer to use the submit buttons.
I have used http://foundation.zurb.com/docs/components/section.html tab forms instead of jQuery's and yes I needed a separate submit button for each form so that it only collected the data from the form it was attached to. You want to create a different form within each div of the tab in question. I found Zurb's Foundation easy to use and they give you code so you only have to tweak it a bit. Here's an example of just one tab using Foundation.
<div class="content" data-slug="panel3" data-section-content="">
<form>
<div class="row collapse">
<div class="large-2 columns">
<label class="inline">Your Name</label>
</div>
<div class="large-10 columns">
<input type="text" id="yourName" placeholder="Jane Smith">
</div>
</div>
<div class="row collapse">
<div class="large-2 columns">
<label class="inline"> Your Email</label>
</div>
<div class="large-10 columns">
<input type="text" id="yourEmail" placeholder="jane#smithco.com">
</div>
</div>
<label>What's up?</label>
<textarea rows="4"></textarea>
<button type="submit" class="radius button">Submit</button>
</form>
</div>
Let me know if this does not answer your question properly.
Add a <form> for each of your tabs.
Add a <input type="submit" value="submit" /> inside each form.
Make sure that none of your forms are nested inside each other.
You should be able to submit each tab independently.
I'm using Bootstrap v2.1.1. I'm finding problem with the width of inputs.
This is my simple form:
<form>
<div class="controls-row">
<div class="span3">
<label class="control-label">A:</label>
<div class="controls">
<input type="text" class="span3"/>
</div>
</div>
<div class="span4">
<label class="control-label">B:</label>
<div class="controls">
<input type="text" class="span4"/>
</div>
</div>
</div>
<div class="controls-row">
<div class="span3">
<label class="control-label">C:</label>
<div class="controls">
<select class="span3">
<option>1111111</option>
<option>2222222</option>
<option>3333333</option>
</select>
</div>
</div>
<div class="span4">
<label class="control-label">D:</label>
<div class="controls">
<input type="text" class="span4"/>
</div>
</div>
</div>
</form>
Using this code the select has a different width, it is NOT the same as <input> with span3 class.
It is very very strange because, if i put span3 in and (using the code above) the width is equal.
COuld someone explain me how can I set equal widths using bootstrap span*
According to the Bootstrap doumentation using the span* classes on your inputs etc should work.
http://twitter.github.com/bootstrap/base-css.html#forms
I'm wondering if it may not be working because you have your form layed out as if it's meant to be a form with the class of "form-horizontal" on it but you don't actually have that class in place.
I'm not sure if a horixontal form can use the span* classes to size it's input elements.
You could try using the "input-block-level" class on your elements instead and see if that does the job for you.
Try adding "inline-block-level"
http://twitter.github.com/bootstrap/base-css.html#forms