My problem is this: I have a flexbox that places a summary section and an image section in a row. The summary section is a nested flexbox that displays the 3 lists as the first column and the horizontal soiltype list as the second column. The problem is that the content of the second column is placed in the center while i want it to align to the left at the same starting position as the lists column above. Here is an image of the current situation:
I have tried using justify-content: flex-start, align-items: flex-start, margin-left: 0px; margin-right: auto; and margin-left:-500px, but everytime the second column remains fixed in the center. Can anyone please tell me what i should do to move the content of the second column to the right? Thank you,
Here is the code:
HTML:
<div class="flexBox flexItem">
<div class="summary">
<div class="flexBox flexItem test">
<ul class="details">
<li><strong>Days until harvest:</strong> {{seedDetails.growthTime}}</li>
<li><strong>Required sun exposure:</strong> {{sunExposure}}</li>
<li><strong>Plant height:</strong> {{seedDetails.plantHeight | measure : distancePipeArgument : true}}</li>
<li><strong>Plant width:</strong> 15 inch</li>
</ul>
<ul class="details">
<li><strong>Germinates after:</strong> 14 days</li>
<li><strong>Germination temperature:</strong> {{seedDetails.growthTemperature | measure: temperaturePipeArgument : true}}</li>
<li><strong>Row spacing:</strong> {{seedDetails.rowSpacing | measure : distancePipeArgument : true}}</li>
<li><strong>Plant spacing:</strong> {{seedDetails.plantSpacing | measure : distancePipeArgument : true}}</li>
</ul>
<ul class="details">
<li><strong>Sow depth:</strong> {{seedDetails.sowDepth | measure : distancePipeArgument : true}}</li>
<li><strong>Life cycle:</strong> {{seedDetails.lifeCycleType | titlecase}}</li>
<li><strong>Hardy at:</strong> {{seedDetails.hardiness | measure: temperaturePipeArgument : true}}</li>
<li><strong>Maximum temperature:</strong> {{seedDetails.maximumTemperature | measure: temperaturePipeArgument : true}}</li>
</ul>
</div>
<div class="soils">
<ul>
<li class="inline"><strong>This plant grows well in:</strong></li><li class="inline">
<mat-chip-list>
<mat-chip style="margin-right:8px; background-color:aquamarine;" *ngFor="let soilType of soilTypes" [selectable]="selectable" (click)="showDialog(soilType)">
{{soilType}}
</mat-chip>
</mat-chip-list></li>
</ul>
</div>
</div>
<figure class="carousel">
<div class="crop shadow">
<input type="image" [src]="seedDetails.imagePreview" class="thumbnail" (click)="showDialog(image)"/>
</div>
<small>Click to view full image</small>
</figure>
</div>
CSS:
.flexItem {
max-width: 1100px;
}
.flexBox{
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
ul.details{
margin-left: 0px;
padding-left: 0px;
flex: 1 1 300px;
}
.inline{
display: inline-block;
}
.soils{
align-items: flex-start;
}
.summary{
display:flex;
flex-direction:column;
justify-content: flex-start;
align-items: flex-start;
/* justify-content: flex-start;
text-align: left; */
width:85%;
/* align-items: flex-start; */
/* border: solid grey 1; */
}
.carousel{
width: 250px;
height: 250px;
/* overflow:hidden; */
background-color: gray;
flex: 1 1 250px;
/* margin-left: 0px; */
}
.crop{
width: 250px;
height: 250px;
overflow:hidden;
}
.shadow{
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.4);
border: 0.5px solid black;
}
.test{
width:850px;
/* border: solid black; */
}
Related
which style or bootstrap or code I should use?
when I add one item, it's placed at the end of this row, but I want they shift into next row.
I attached 2 pic of my implementation.
(if the codes are required I attach them.)
pic1
pic2
<div class="layoutpost" >
{% for post in posts %}
<div class="post">
<div class="img-post">
<img src="{{post.urls}}" alt="">
</div>
<div class="postdescribe">
<div>{{post.title}}</div>
<div class="price">price: {{post.price}}</div>
<div class="more">
more...
</div>
</div>
</div>
</div>
.layoutpost{
display: flex;
justify-content: space-around;
}
.post{
width: 20%;
border: 0.5px solid;
}
.postdescribe{
margin-left: 10px;
margin-bottom: 10px;
}
.img-post{
width: 100%;
height: 300px;
}
.img-post img {
height: 90%;
width: 100%;
}
You can get the desired output by adding the below code, and instead of using space-between, you can add space-evenly to beautify it.
.layoutpost{
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
}
I'm working on a sidebar using Angular and Flex. It's app-sidebar within the following layout Angular component:
<div fxlayout="row" fxFill>
<app-sidebar fxLayout="column" fxFlex="10%"></app-sidebar>
<div fxLayout="column" fxFlex="100">
<app-top-navbar class="navbar-component" fxLayout="column"></app-top-navbar>
<div class="content" fxLayout="column" fxFlex>
<router-outlet></router-outlet>
</div>
</div>
</div>
I'm trying to get the sidebar to fill the page vertically, the list items within evenly spaced between that expanse. But I'm not having any luck... I've made a simplified version in this JSFiddle. You can see that it stretches horizontally (great, as I want it to fill that 10% of the greater layout), but it doesn't go to the bottom of the page.
I'm new to Angular and Flex, so any help would be appreciated. Here's the Fiddle code (if it makes a difference, anchors are used, because I also have icons not included):
:host {
display: flex;
flex-direction: column;
flex: 1 1 100%;
}
#sidebar-cont-div{
display: flex;
flex:1;
flex-direction: column;
}
#navbar-content-container{
display: flex;
flex: 1;
flex-direction: column;
}
#main-navbar {
background-color: red;
border-radius: 50px 20px 20px 50px;
text-align:center;
}
#nav-list {
padding: 0;
list-style: none;
display: flex;
flex-direction: column;
justify-content: space-around;
flex: 1;
margin: auto;
min-width:100%;
height:100%;
}
<div id = "sidebar-cont-div">
<nav id="main-navbar">
<div id="navbar-content-container">
<a href="#">
<h1 id="sidebar-logo">Project<br>Dash</h1>
</a>
<ul id="nav-list">
<li class="sidebar-item" role="presentation">
<a href="#">
<span>Overview</span>
</a>
</li>
<li class="sidebar-item" role="presentation">
<a href="#">
<span>Project Record</span>
</a>
</li>
</ul>
</div>
</nav>
</div>
please try like this
body , html {
height:100% ;
margin : 0px ;
}
#sidebar-cont-div{
display: flex;
flex-direction: column;
height:100%
}
#main-navbar {
background-color: #ffffff;
background-image: linear-gradient(180deg,rgba(127,162,137,0.82) 20%,rgba(39,86,94,0.92));
border-radius: 50px 20px 20px 50px;
text-align:center;
display: flex;
flex-direction: column;
flex: 1 1 auto;
}
You can use the rest of the style as it is.By using the styles above your side nav will strech vertically.
working sample in stackblitz
https://stackblitz.com/edit/js-aqedvi
Scenario :
I'm creating a pricing comparison table and am having difficulties aligning the last div, card-vat-fee, to the bottom of the container.
I need to do this because the tiers have longer running lists than
one another, causing the last div isn't aligned with the bottom of
the container.
How can I get the last div to align to the bottom of the flexbox?
Tried Case :
Of course, if I set a min-height: 320px; on the card-vat-fee class it will align the div to the bottom, however this isn't a responsive solution and I feel like there is a better approach that uses flex properties. Moreover, setting the card-vat-fee div to flex-grow, flex: 1 1 auto, produces an unideal solution.
Code :
<div class='pricing__tier'>
<div class='uni-card-header'>
</div>
<div class='uni-card-body'>
<div class='uni-row-on'>
</div>
<div class='uni-row-off'>
</div>
<div class='uni-row-on card-vat-fee'>
<div class='vat-fee-text'>
Credit card fees and VAT apply. See below for details.
</div>
</div>
</div>
</div>
<style>
.pricing__tier {
padding: 0;
text-align: center;
display: flex;
flex-direction: column;
width: 0%;
flex: 1;
}
.uni-card-body {
display: flex;
flex-direction: column;
}
</style>
Pricing Tier
Please Suggest.
Thanks in advance
Use margin-top:auto on the last div.
.pricing__tier {
padding: 0;
text-align: center;
display: flex;
flex-direction: column;
width: 25%;
flex: 1;
height: 200px; /* for demo purposes */
border: 1px solid grey;
}
.uni-card-body {
display: flex;
flex-direction: column;
flex: 1;
}
.card-vat-fee {
margin-top: auto; /* push to bottom */
background: green;
}
<div class='pricing__tier'>
<div class='uni-card-header'>
</div>
<div class='uni-card-body'>
<div class='uni-row-on'>
</div>
<div class='uni-row-off'>
</div>
<div class='uni-row-on card-vat-fee'>
<div class='vat-fee-text'>
Credit card fees and VAT apply. See below for details.
</div>
</div>
</div>
</div>
plaesa try this one :
.uni-card-body {
display: flex;
flex-direction: column;
width: 'for example' 700px;
}
.uni-row-on.card-vat-fee{
align-self: flex-end;
}
Ihope this will help you!
.uni-card-body {
display: flex;
flex-flow: row wrap;
justify-content: center;
background: yellow;
height: 90vh;
}
.uni-row-on.card-vat-fee {
align-self: flex-end;
background: green;
}
<div class='pricing__tier'>
<div class='uni-card-header'>
</div>
<div class='uni-card-body'>
<div class='uni-row-on'>
</div>
<div class='uni-row-off'>
</div>
<div class='uni-row-on card-vat-fee'>
<div class='vat-fee-text'>
Credit card fees and VAT apply. See below for details.
</div>
</div>
</div>
</div>
I've illustrated the thing in the snippet, it'll help.
Note: Content justification, background and height are for demonstration and not necessary.
1- set the parent div relative position without top & left & right &
bottom property
2- set the last div position absolute with bottom:0;right:0;left:0;height:36px;
<style>
.pricing__tier {
position:relative;
padding: 0;
text-align: center;
display: flex;
flex-direction: column;
width: 0%;
flex: 1;
}
.pricing__tier>.vat-fee-text {
position:absolute;
bottom:0;
right:0;
left:0;
height:36px;
}
</style>
I have been struggling with this CSS layout. I have n items that its amount might increase dynamically. And I want to only just have n rows and many or unlimited columns layout.
So, let's say that n is 2 and I have 3 items, This is how my items should look like,
-----------
| 1 || 3 |
-----------
| 2 |
-----------
For the same n, with 6 items,
-----------------
| 1 || 3 || 5 |
-----------------
| 2 || 4 || 6 |
-----------------
And so on..
I have tried tinkering it with float: left with no lucks. And now I am kinda learning flex layout, which leads me to stuck.
Please help :) Here's my Fiddle
Note: All my items will have the same width and height.
Something like this?
jsFiddle 1
.items {
display: flex;
flex-direction: column;
flex-wrap: wrap;
}
/* Below this is just styling */
.items {
background-color: #0f9c8a;
padding: 4px;
height: 250px;
width: 100%;
}
.item {
width: 100px;
height: 100px;
background-color: #6f6ac2;
border: 1px solid #fff;
margin: 2px;
text-align: center;
line-height: 100px;
}
<div class="items">
<div class="item">
Item 1
</div>
<div class="item">
Item 2
</div>
<div class="item">
Item 3
</div>
<div class="item">
Item 4
</div>
<div class="item">
Item 5
</div>
</div>
Update: since you need to align the .item divs to the left just add align-content:flex-start; to the container .items, like this:
jsFiddle 2
.items {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: flex-start;
}
/* Below this is just styling */
.items {
background-color: #0f9c8a;
padding: 4px;
height: 250px;
width: 1000px;
}
.item {
width: 100px;
height: 100px;
background-color: #6f6ac2;
border: 1px solid #fff;
margin: 2px;
text-align: center;
line-height: 100px;
}
<div class="items">
<div class="item">
Item 1
</div>
<div class="item">
Item 2
</div>
<div class="item">
Item 3
</div>
<div class="item">
Item 4
</div>
<div class="item">
Item 5
</div>
</div>
I'm trying to make my first custom header.
I want the middle item (eg. the logo) to stay centered regardless of how much content is on either side.
I tried using z-index but I believe that was wrong.
HTML:
.flex-container {
padding: 0;
margin: 0;
list-style: none;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
.flex-item {
text-align: center;
}
.image {
z-index: -1;
}
<div id="header_container">
<div id="header">
<ul class="flex-container">
<li class="flex-item">Menu items 1 BHello | seven | eight | nineteen | Fitiyytwooooo
</li>
<li class="image">
<img src="http://www.plankdesign.com/wp-content/uploads/2011/01/html4.jpg" style="width:204px;height:128px;">
</li>
<li class="flex-item">Menu items 2 Blah | Blah | Blah</li>
</ul>
</div>
</div>
Here's my jsfiddle demo.
Try like this: Demo
.image img {
z-index: 1000;
width:18%;
height:128px;
position:absolute;
left:50%;
margin-left:-9%; /* half of the width */
}
HTML:
<li class="image">
<img src="http://www.plankdesign.com/wp-content/uploads/2011/01/html4.jpg" />
</li>
Check this out, you may want to modify the code(col-md-x) as per your requirement.