CSS display inline makes two rows instead of one - css

What should I use if my layout looks good without the display element, then I must add display: none which is set dynamically to display: block which destroys my layout. Is there no "normal" display? I have tried inline and it doesn't work either. I want to first set it to display: none and then I want it to look like it had no or "normal" display property.
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/semantic.min.css" rel="stylesheet"
type="text/css">
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="center jumbotron">
<div class="container" style="margin-top:20px; width: 75%">
<h4 class="ui header">Semantic UI Form</h4>
<form name="formular" class="ui form">
<div class="ui grid">
<div class="four wide column ">
<label>First Name</label>
</div>
<div class="twelve wide column">
<input type="text" name="first-name" placeholder="First Name">
</div>
</div>
<div class="ui grid">
<div class="four wide column ">
<label>Last Name</label>
</div>
<div class="twelve wide column">
<input type="text" name="first-name" placeholder="Last Name">
</div>
</div>
<div class="ui grid" id="category_contents">
<div class="four wide column ">
<label>Last Name</label>
</div>
<div class="twelve wide column">
<input type="text" name="first-name" placeholder="Last Name">
</div>
</div>
<div style="display: inline;" id="categor2y_contents" class="ui grid">
<div class="four wide column ">
<label>Last Name</label>
</div>
<div class="twelve wide column">
<input type="text" name="first-name" placeholder="Last Name">
</div>
</div>
<!-- <button class="ui button" type="submit">Submit</button> -->
</form>
</div>
</div>
</div>
</div>
Update
The solution was to add an extra <div class="ui grid"> but how am I supposed to know that?

If I understand your question, you are wanting to revert back to an element's initial state of display after you've overwritten it with display:none; correct? If so, simply:
#element {
display: initial;
}
https://developer.mozilla.org/en-US/docs/Web/CSS/initial

The solution was to add another ui grid. I found this solution from another answer How to align my label and input field
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.2/semantic.min.css" rel="stylesheet"
type="text/css">
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="center jumbotron">
<div class="container" style="margin-top:20px; width: 75%">
<h4 class="ui header">Semantic UI Form</h4>
<form name="formular" class="ui form">
<div class="ui grid">
<div class="four wide column ">
<label>First Name</label>
</div>
<div class="twelve wide column">
<input type="text" name="first-name" placeholder="First Name">
</div>
</div>
<div class="ui grid">
<div class="four wide column ">
<label>Last Name</label>
</div>
<div class="twelve wide column">
<input type="text" name="first-name" placeholder="Last Name">
</div>
</div>
<div style="display: block;" class="ui grid" id="category_contents">
<div class="ui grid">
<div class="four wide column ">
<label>Last N2ame</label>
</div>
<div class="twelve wide column">
<input type="text" name="first-name" placeholder="Last Name">
</div>
</div>
<!-- <button class="ui button" type="submit">Submit</button> -->
</form>
</div>
</div>
</div>
</div>

Related

Bootstrap form with fixed column width

I have an inline form with the following code:
<div class="card" style="width:100%;">
<div class="card-block">
<form class="form-inline">
<div class="row">
<div class="form-group col-xs-2">
<label for="displayName">Display Name</label>
<input class="form-control" ng-model="displayName" style="height:30px;" id="displayName">
</div>
<div class="form-group col-xs-2">
<label for="officeEmail">Office Email</label>
<input class="form-control" ng-model="officeEmail" style="height:30px;" id="officeEmail">
</div>
</div>
</form>
</div>
</div>
when I run it it looks like this:
When I resize the Browser it's looking like this:
My question is how I can have input fields with fixed width and fixed distance between columns?
Thanks
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="card" style="width:100%;">
<div class="card-block">
<form class="form-inline">
<div class="row">
<div class=" col-lg-3 col-md-3 col-sm-3 col-xs-3">
<label for="displayName">Display Name</label>
<input class="form-control" ng-model="displayName" style="height:30px;" id="displayName">
</div>
<div class=" col-lg-3 col-md-3 col-sm-3 col-xs-3">
<label for="officeEmail">Office Email</label>
<input class="form-control" ng-model="officeEmail" style="height:30px;" id="officeEmail">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
Is this the same that you are looking for?
Hope this helps.

Make input-group same height as col

I have a form with two rows (col-md-6). On the left side there are some fields, on the right side, there's only one textarea.
Now what I wanted to do is make the textarea the same height as all the other fields together.
I thought this would be easily possible when setting a display: flex; to the row, so that the tow col-md-6's are the same height and then add height: 100% to the input-group, but unfortunately I was wrong. The input will not expand to the full height.
Here's my HTML code:
<div class="row" style="display: flex;">
<div class="col-md-6">
<div class="input-group">
<div class="input-group-addon">Input 1:</div>
<input type="text" class="form-control"></textarea>
</div>
<div class="input-group">
<div class="input-group-addon">Input 2:</div>
<input type="text" class="form-control"></textarea>
</div>
<div class="input-group">
<div class="input-group-addon">Input 3:</div>
<input type="text" class="form-control"></textarea>
</div>
</div>
<div class="col-md-6">
<div class="input-group" style="height: 100%;">
<div class="input-group-addon">Textarea:</div>
<textarea class="form-control" style="height: 100%"></textarea>
</div>
</div>
</div>
I added the styles inline to reduce the code here on stackoverflow.
So again, I could get the two columns to the same height, but I'm unable to set the height of the textarea to 100%.
Can anyone tell how this could work? If possible without JavaScript!
textarea {
height: 100%;
}
<div class="row" style="display: flex;">
<div class="col-md-6">
<div class="input-group">
<div class="input-group-addon">Input 1:</div>
<input type="text" class="form-control">
</div>
<div class="input-group">
<div class="input-group-addon">Input 2:</div>
<input type="text" class="form-control">
</div>
<div class="input-group">
<div class="input-group-addon">Input 3:</div>
<input type="text" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="input-group" style="height: 100%;">
<div class="input-group-addon">Textarea:</div>
<textarea class="form-control"></textarea>
</div>
</div>
</div>

Height issue with segment inside to grid column

I have a grid with 2 columns in it. In column one I have 1 raised segment, in column two I have 2 raised segments. Obviously, the second column will be larger. I need the segment in column one to take on full height. Any ideas?
Thanks!
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.js"></script>
<link href="//oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.css" rel="stylesheet" />
<div class="ui padded grid">
<div class="eight wide column">
<div class="ui raised segment">
<h3>Header 1</h3>
<i>Select all that apply</i>
<br />
<br />
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="id1" name="id1" value="1" tabindex="0" />
<label>Information about widgets</label>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="id2" name="id2" value="1" tabindex="0" />
<label>Additional information about widgets</label>
</div>
</div>
</div>
</div>
<div id="extraColumn" class="eight wide column">
<div class="ui raised segment">
<h3>Question 1</h3>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="content_1" name="content_1" value="1" tabindex="0" />
<label>Include Sprockets</label>
</div>
</div>
</div>
<div class="ui raised segment">
<h3>QUestion 2</h3>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="content_2" name="content_2" value="1" tabindex="0" />
<label>Don't include sprockets</label>
</div>
</div>
</div>
</div>
</div>
Semantic UI used CSS Flexbox, and grid is declared in a way so that the heights of adjacent columns match. So all you need to do is make sure your left segment has a height of 100% to fill the full height of your column.
Result:
<div class="ui raised segment" style="height:100%;">
Snippet:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.js"></script>
<link href="//oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.css" rel="stylesheet" />
<div class="ui padded grid">
<div class="eight wide column">
<div class="ui raised segment" style="height:100%;">
<h3>Header 1</h3>
<i>Select all that apply</i>
<br />
<br />
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="id1" name="id1" value="1" tabindex="0" />
<label>Information about widgets</label>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="id2" name="id2" value="1" tabindex="0" />
<label>Additional information about widgets</label>
</div>
</div>
</div>
</div>
<div id="extraColumn" class="eight wide column">
<div class="ui raised segment">
<h3>Question 1</h3>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="content_1" name="content_1" value="1" tabindex="0" />
<label>Include Sprockets</label>
</div>
</div>
</div>
<div class="ui raised segment">
<h3>QUestion 2</h3>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="content_2" name="content_2" value="1" tabindex="0" />
<label>Don't include sprockets</label>
</div>
</div>
</div>
</div>
</div>

Bootstrap 3 - Division of columns

Assume we have two rows:
1 Row with col-md-12
1 Row with 2 divs, each of col-md-6
In the first row, I have Label/Textbox in a form-horizontal way. An example is shown below.
My question is, does the div with class form-group give me a row of width 12 columns? How to align content when I have rows including columns of different width? For instance, I need to align the sub button to be aligned with the Textbox, not the Label.
I am realizing that when I use a div.form-group, then I get the chance to have new 12 columns, even though the div.form-group is inside a div.col-md-6. Is this correct?
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row">
<div class="col-xs-11 col-md-6">
<div class="form-group">
<label for="txtFirstName" class="control-label col-md-3 col-xs-3">First Name</label>
<div class="col-md-7 col-xs-8">
<input type="text" class="form-control" id="txtFirstName">
</div>
</div>
</div>
<div class="col-xs-11 col-md-6">
<div class="form-group">
<label for="txtLastName" class="control-label col-md-3 col-xs-3">Last Name</label>
<div class="col-md-7 col-xs-8">
<input type="text" class="form-control" id="txtLastName">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-11 col-md-6">
<div class="form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
you will have to use class 'row' to make it into col-6 div.
<div class="col-xs-11 col-md-6">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-xs-3">
<label for="txtFirstName" class="control-label">First Name</label>
</div>
<div class="col-md-7 col-xs-8">
<input type="text" class="form-control" id="txtFirstName">
</div>
</div>
</div>
</div>
Check http://getbootstrap.com/css/ , Nesting columns section

Overlapping columns after resizing in Bootstrap 3.0

Why in the following Bootstrap 3.0 sample the right panel hides completely the form when I reduce the width of the browser?
<div class="row">
<div class="col-sm-9">
<h2>Product selection</h2>
<p>Some text</p>
<hr />
<form action="/Store" class="form-horizontal" id="productForm" method="post" role="form">
<div class="form-group">
<label class="col-md-2 control-label" for="Quantity">Quantity</label>
<div class="col-md-10">
<input class="form-control" id="quantity" name="quantity" onchange="this.form.submit();" type="text" value="1" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input name="nextButton" type="submit" class="btn btn-default" value="Next" />
</div>
</div>
</form>
</div>
<div class="col-md-3" style="margin-top: 20px">
<div class="panel panel-default">
<div class="panel-heading">Your Options</div>
<div class="panel-body">
<p style="line-height: 200%">
Other ways to buy<br/>
</p>
</div>
</div>
</div>
Here is a live test of what happens:
http://www.bootply.com/R4FsSHI4af
To reproduce it you need simply to reduce the width of the browser window.
Thanks.
You are mixing col-sm-9 with col-md-3. Just use one size, for example col-md-9 and col-md-3.
Use this structure instead :
<div class="row">
<div class="col-md-9">
<!-- Content -->
</div>
<div class="col-md-3">
<!-- Panel -->
</div>
</div>
As you're mixing col-sm-9 and col-md-3, you've got :
a 12-12 pattern on small devices
a 9-12 pattern on medium devices : overlap
a 9-3 pattern on large and extra large devices

Resources