How can I make one div to take certain percent of parent space verically?See the code below:
<div layout="column">
<div id="div1" flex="70%"></div>
<div id="div2" flex="30%"></div>
</div>
I want to make div1 70% height and div2 30% height of parent div. But it does not work. Div 1 and div 2 collapsed. But if the parent layout is row, it works fine---div1 takes 70% percent space horizontally.
I think you need to make the following modifications:
Specify a "height" to your outside div. This could be a percentage or pixels.
Do not use the % sign with the flex attribute
See this codepen: http://codepen.io/sebastiengiroux/pen/jPovxG
<div layout="column" style="height: 100%;">
<div id="div1" flex="70" style="background-color:red;"></div>
<div id="div2" flex="30" style="background-color:blue;"></div>
</div>
If you look into Layout docs https://material.angularjs.org/latest/layout/introduction
there is this statement that I think is relevant to your problem.
The flex attribute value is restricted to 33, 66, and multiples of five.
For example: flex="5", flex="20", flex="33", flex="50", flex="66", flex="75", ....
So I guess if you use allowed values, you can achieve results that you need. For example using 66 and 33.
Related
I've run into some issues with vertical alignment for an image (using bootstrap 5).
In the index.html I've created a number of thick strips that alternate being colour and then white, with each about 800 px each. I've set the height of each strip in css to 800px.
I'm trying to place an image in each strip and the image sizes will differ in width but none will be greater than 800 px in height. The image doesn't seem to be vertically centred when I used the suggestions from the post below:
Bootstrap Center Vertical and Horizontal Alignment
There is this example given https://www.codeply.com/p/0VM5MJ7Had
And the div tag used to center everything is
<div class="d-flex flex-column min-vh-100 justify-content-center align-items-center">
In the tag above if the min-vh-100 is removed then the content just moves up to the top of the screen even though it's still justify-content-center and align-items-center.
I'm still struggling to get my head around how vertical alignment works and the relationship between containers and rows to aligning an image vertically.
<!-- color background -->
<div id="first_strip" >
<img src="../images/" class="img-fluid" alt="" />
</div>
<!-- white background -->
<div id="second_strip">
<img src="../images/" class="img-fluid" alt="" />
</div>
<!-- color background -->
<div id="third_strip" >
<img src="../images/" class="img-fluid" alt="" />
</div>
etc.
I looked at the documentation for Bootstrap 5 but I can't seem to find the min-width class using pixels? Is there any?
https://v5.getbootstrap.com/docs/5.0/utilities/sizing/
Bootstrap CSS Grid layout does the heavy lifting in terms of setting responsive breakpoints.
Each view/page/front-end element can be divided into 12 parts. and you can choose how much space a container takes out of 12 vertical columns.
Bootstrap 5 gives you 6 breakpoints pre-defined, with the following syntax
col-xs-{number-between-1-to-12} width <= 540px
col-sm-{number-between-1-to-12} max-width = 540px
col-md-{number-between-1-to-12} max-width = 720px
col-lg-{number-between-1-to-12} max-width = 960px
col-xl-{number-between-1-to-12} max-width = 1140px
col-xxl-{number-between-1-to-12} width <= 1400px
Example 1: You get a parent div with 2 child divs, these children will take equal divided space inside for all screen sizes
<div id="i-am-a-parent-div">
<div class="col-6"> This takes First Half the Space inside parent element</div>
<div class="col-6"> This takes Second Half the Space inside parent element</div>
</div>
Example 2: The Children divs will share 6/12 space each till max-width=540, but then they will change space occupation to 4/12 and 8/12 respectively.
NOTE: I've added two separated classes for each child div, you can add as many as needed for each breakpoint.
<div>
<div class="col-sm-6 col-md-4"> This takes First Half (6/12) the Space inside parent element till max-width = 540px,
BUT it will only take One-Thirds (4/12) the space between 540px & 768px </div>
<div class="col-sm-6 col-md-8"> This takes Second Half (6/12) the Space inside parent element till max-width = 540px,
BUT it will only take Two-Thirds (8/12) the space between 540px & 768px </div>
</div>
If this doesnt satisfy what you need to do, Then there are more customization options to their breakpoints, Feel free to checkout: https://v5.getbootstrap.com/docs/5.0/layout/grid/#grid-options
Let me know if this helps you out!
Recent upgrade to Bootstrap 3 on a Rails app. SimpleForm text box and also other form inputs are too large - they are erroneously full-page in length. The app does have responsive design, and the form input boxes do resize.
I'd like to limit the form input size to 50% instead of full page.
I did add this initializer gist https://gist.github.com/tokenvolt/6599141 but it did not seem to have an effect.
I am unfamiliar with the Bootstrap3/Simpleform2.1.1 conflicts.
I adjusted the width to 50% in the application.css.scss, but that did not make a clean change
/* forms */
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
padding: 10px;
margin-bottom: 15px;
#include box_sizing;
}
By length do you mean width? If you don't want the form to be too wide you could divide the page into columns and then put the form into a smaller column.
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<%= simple_form-for...
</div>
</div>
Bootstrap uses a gridsystem that divides the page into 12 columns. if you just put the form on, it will take up all 12 columns (the whole page) so you need to specify how many columns you want the form to take up. Here's a post that really helped me understand the new gridsystem: http://blog.jetstrap.com/2013/08/bootstrap-3-grids-explained/
So i have this div containing a contact script:
<div id="contactbox" style="">
<form enctype="multipart/form-data" method="post" action="http://www.response-o-
matic.com/mail.php" accept-charset="UTF-8">here's the script</form>
</div>
</div>
I'm wondering if there is any way to align a script after the wrapper size for every resolution.Because i set the position of the script in percentage and on my resolution it looks centered in wrapper.But on a bigger resolution for example it's not working,it's a little bit in left side,that means the script goes after the html size because it focuses after it and it goes in the middle.
I know that if i set the wrapper with:
.wrapper
{
text-align:center;
}
then every texts from the wrapper will be centered after his size,but with scripts isnt working.So is there any way?
I'm using a <div data-role='fieldcontain'> to make a "box" where there are two fields "min" and "max" the problem is that I want to have two parts in the same line, but jquery mobile separes in two lines if display width is smaller than size jquery wants. I try to put width of two components, but it still separes in two lines and the label and text box are smaller than half display...
this is my code:
<div data-role='fieldcontain' id='TempLimits'>
<label for='Tmin' style='display-inline;width:100;'>Min
<input type='text' name='Tmin' id='Tmin' value='50' disabled='disabled' style='display:inline;width:50px;'/></div>
Thanks,
This is the solution I found:
<div data-role='fieldcontain' id='TempLimits'>
<label for='Tmin' style='display-inline;width:100;'>Min
<input type='text' name='Tmin' id='Tmin' value='50' disabled='disabled' style='display:inline-block;width:50px;'/></div>