I'm trying to pass the last two items over each other as shown on the bottom of this photo.
Is this possible as is by forcing a line break or do I have to change the display of the parent div?
The HTML structure looks like this :
<div class="wp-block-cover">
<ul class="articleslisteshp" id="lcp_instance_0">
<li>
<a>Lorem ipsum article title</a>
<span class="testcat" style="width: 100%;">
<a>Category1</a>
<a>Category2</a>
</span>
<a><img width="150" height="150"></a>
</li>
</ul>
</div>
Et voici le CSS que j'ai essayƩ :
ul.articleslisteshp{
display: flex;
flex-direction: column;
}
ul.articleslisteshp > li{
display: flex;
flex-direction: row-reverse;
}
I would take out the a tag from inside the list if possible and put it outside of it. Like so:
<div class="wp-block-cover">
<ul class="articleslisteshp" id="lcp_instance_0">
<a><img width="150" height="150"></a>
<li>
<a>Lorem ipsum article title</a>
<span class="testcat" style="width: 100%;">
<a>Category1</a>
<a>Category2</a>
</span>
</li>
</ul>
</div>
And use the following CSS to achieve what you asked for:
ul.articleslisteshp{
display: flex;
flex-direction: row;
}
ul.articleslisteshp > li{
display: flex;
flex-direction: column-reverse;
}
span.testcat {
display: flex;
flex-direction: column;
}
Related
I have the following HTML:
<div class="icon-box">
<div class="icon">
<svg>...</svg>
</div>
<h3>Title here</h3>
<p>Lorem ipsum dolor...</p>
</div>
My CSS:
.icon-box {
display: flex;
}
The result:
How can i get the following using flexbox without changing the HTML:
I am trying to align the icon to left and the heading and paragraph to its right on the same column. Without changing/adding new HTML.
Try using flex-direction: column; on main parent and regular display: flex; (flex-direction: row;) on the child of parent.
.icon-box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.icon {
display: flex;
gap: 10px;
}
<div class="icon-box">
<div class="icon">
<img src="https://dummyimage.com/50/000000/f2009d&text=SVG">
<h3>Title here</h3>
</div>
<p>Lorem ipsum dolor...</p>
</div>
.fill-viewport-50 {
min-height: 50%;
min-height: 50vh;
}
.navigation-bar {
display: flex;
padding-top: 2rem;
margin-bottom: auto;
height: $navigation-bar-height;
justify-content: flex-end;
}
.hero-content {
margin-top: -$navigation-bar-height;
margin-bottom: auto;
}
#header .container {
flex-direction: column;
justify-content: center;
}
<div class="container d-flex fill-viewport-50">
<div class="navigation-bar align-items-center">
<span class="navigation-brand">
Ware Aquatics
</span>
<ul class="d-none d-md-block navigation-links list-inline">
<li class="navigation-link list-inline-item"><a {{ Request::is( '/') ? 'class=active-link': null }} href="{{ route('index') }}">Home</a></li>
<li class="navigation-link list-inline-item"><a {{ Request::is( 'livestock') ? 'class=active-link': null }} href="{{ route('livestock') }}">Livestock</a></li>
<li class="navigation-link list-inline-item">Products</li>
<li class="navigation-link list-inline-item">FAQ</li>
<li class="navigation-link list-inline-item"><a {{ Request::is( 'contact') ? 'class=active-link': null }} href="{{ route('contact') }}">Contact Us</a></li>
</ul>
</div>
<div class="hero-content">
<div class="row">
<div class="col-12">
<h1>#yield('title')</h1>
<h2>#yield('subtitle')</h2>
</div>
</div>
</div>
</div>
Chrome & other browsers
Internet Explorer 11
Does anyone have any ideas? Not too sure what's going wrong here.
I managed to fix this by applying the .fill-viewport-50 class to the .hero-content row instead and changing min-height to height for IE11+.
I need help horizontally aligning child elements in parent flex boxes.
The layout below shows a flex container (".parent") showing 4 parent containers (".child"):
Please take a look at this flexbox graphic
(I can't show my actual project so I mocked it up in Illustrator.)
The green box (top) represents a variable text headline (max 3 lines).
The blue box (second one down) represents an image with fixed height and width(I want these images to be aligned on top).
The yellow box represents a paragraph of varying copy.
The purple box on the bottom is another fixed-height flex box.
I have the following code (in LESS):
.parent {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-flow: wrap;
flex-wrap: wrap;
.child {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex: 1;
-ms-flex:1;
flex:1;
-webkit-flex-flow: column;
-ms-flex-flow: column;
flex-flow: column;
-webkit-align-content: space-around;
align-content: space-around;
.green {
-webkit-align-items: baseline;
-ms-flex-align: baseline;
align-items: baseline;
}
.blue {
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
}
.purple {
-webkit-flex: 1;
-ms-flex:1;
flex:1;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row;
-ms-flex-flow: row;
flex-flow: row;
-webkit-align-items: flex-end;
-ms-flex-align: end;
align-items: flex-end;
-webkit-order: 3;
-ms-flex-order: 3;
order: 3;
}
.yellow {
-webkit-order: 2;
-ms-flex-order: 2;
order: 2;
}
}
}
EDIT - and here's the HTML code:
<section class="parent">
<article class="child">
<a href="#">
<h3 class="green">Title of article</h3>
<div class="blue"><img class="img-responsive" src="/stuff/headerImage.png" /></div>
</a>
<section class="purple">
<div class="authorImage"><img src="/writers/JohnDoe.jpg") /></div>
<h4 class="authorTitle">by John Doe</h4>
</section>
<p class="yellow">Paragraph introducing article summary.</p>
</article>
<article class="child">
<a href="#">
<h3 class="green">Title of article</h3>
<div class="blue"><img class="img-responsive" src="/stuff/headerImage.png" /></div>
</a>
<section class="purple">
<div class="authorImage"><img src="/writers/JohnDoe.jpg") /></div>
<h4 class="authorTitle">by John Doe</h4>
</section>
<p class="yellow">Paragraph introducing article summary.</p>
</article>
<article class="child">
<a href="#">
<h3 class="green">Title of article</h3>
<div class="blue"><img class="img-responsive" src="/stuff/headerImage.png" /></div>
</a>
<section class="purple">
<div class="authorImage"><img src="/writers/JohnDoe.jpg") /></div>
<h4 class="authorTitle">by John Doe</h4>
</section>
<p class="yellow">Paragraph introducing article summary.</p>
</article>
<article class="child">
<a href="#">
<h3 class="green">Title of article</h3>
<div class="blue"><img class="img-responsive" src="/stuff/headerImage.png" /></div>
</a>
<section class="purple">
<div class="authorImage"><img src="/writers/JohnDoe.jpg") /></div>
<h4 class="authorTitle">by John Doe</h4>
</section>
<p class="yellow">Paragraph introducing article summary.</p>
</article>
</section>
I'm having trouble integrating react-widgets (Dropdownlist and Multiselect) with my styling in the same way as the input-fields I've used before.
It should look like this:
With the white rectangles beeing react-widgets Dropdownlists respectively Multiselect.
Here's a codepen-example, with the second blue block containing react-widget's markup: http://codepen.io/peletiah/pen/ORLaGr
This is the relevant (simplified) markup:
.route {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
}
.sequence {
display: flex;
height: 90px;
line-height: 90px;
}
.action {
align-self: center;
line-height: normal
}
<div class="route">
<div class="sequence">
<div class="action">
<span>
<input value="set">
</span>
<span>
<input value="data goes here">
</span>
</div>
</div>
<div class="sequence">
<div class="action">
<div class="rw-dropdownlist rw-widget">
<div class="rw-input">set</div>
</div>
<div class="rw-multiselect rw-widget">
<div class="rw-multiselect-wrapper">
<input>
</div>
</div>
</div>
</div>
</div>
The markup inside the action-div in the second "sequence" is produced by react-widget, so I have a no influence and can't easily replace them with spans.
The widgets are supposed to be aligned next to each other like the inputs in the first sequence, but they are stacked on top of each other.
Is it possible to fix this with css?
In the codepen-example above I've included the react-widgets less-code in the upper part of the css-section of the codepend, at then end of it is my custom css.
There where two issues with the original code-sample.
Vertical alignment of the "action"-container inside the "sequence"-container was achieved by setting "line-height".
The line-height is also responsible for the 90px-high "rw-multiselect-wrapper"-div, which it inherits from the "sequence"-class.
Flexbox allows self-alignment of children with the "align-self"-property.
Adding an "align-self" to the class and wrapping each react-widget-div's in their own "action"-div fixes the alignment issue and the height-issue.
.route {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
}
.sequence {
display: flex;
}
.action {
align-self: center;
}
<div class="route">
<div class="sequence">
<div class="action">
<span>
<input value="set">
</span>
</div>
<div class="action">
<span>
<input value="data goes here">
</span>
</div>
</div>
<div class="sequence">
<span class="sequence-order">2</span>
<div class="action">
<div class="rw-dropdownlist rw-widget">
<div class="rw-input">bridge</div>
</div>
</div>
<div class="action">
<div class="rw-multiselect rw-widget">
<div class="rw-multiselect-wrapper">
test
<input>
</div>
</div>
</div>
</div>
</div>
Codepen-sample: http://codepen.io/peletiah/pen/ozjNpW
I'm trying to move around text with justify-content with flex box and whilst align-items works to move the content vertically, justify-content doesn't work to move the content horizontally.
I know I can use text-align, however I don't like how it moves all the text to the far right including the sub-title text, which I want to start at the same place as the title does - I believe this would be what justify-content would do.
CodePen: http://codepen.io/gutterboy/pen/yYxmLP
HTML:
<div id="main-slider" class="carousel">
<div class="container">
<div class="row">
<div class="col-sm-offset-1 col-sm-10">
<div class="carousel-inner" role="listbox">
<div class="item item1 active">
<img src="http://dreamatico.com/data_images/car/car-1.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
<div class="item item2">
<img src="http://dreamatico.com/data_images/car/car-8.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<ol class="carousel-indicators">
<li data-target="#main-slider" data-slide-to="0" class="active"></li>
<li data-target="#main-slider" data-slide-to="1"></li>
</ol>
CSS:
.item {
position: relative;
.details {
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
padding: 25px;
color: #fff;
z-index: 2;
align-items: flex-end;
justify-content: center;
h2 {
margin-top: 0;
}
}
&.item2 {
.details {
align-items: flex-start;
justify-content: flex-start;
}
}
}
.fix-flex {
width: 100%;
}
.flex-row {
display: flex;
flex-flow: row nowrap;
}
There is more CSS related to the code, but it's related to bootstrap.
The issue you are having is due to your fix-flex class. It has a width of 100%. It is being centered with justify-content:center but since the element is the same size of its container it is not visually obvious that it is working. Check out my fork of your codepen.
Fork of your codepen
This should be removed
.fix-flex {width:100%;}
After reading #paulie_D's comments I realised it had to do with the fix-flex class which had a style of width: 100%; set and was wrapped around the content I was trying to justify and hence it really couldn't move it.
This was also pointed out by Adrian Eufracio's answer; however removing the div altogether would cause the issue I was trying to prevent; so I had to leave the div in the code but just remove the width: 100%; from the styles and I can now justify the content and the text doesn't wrap.
CodePen: http://codepen.io/gutterboy/pen/jbeOrP
HTML:
<div id="main-slider" class="carousel">
<div class="container">
<div class="row">
<div class="col-sm-offset-1 col-sm-10">
<div class="carousel-inner" role="listbox">
<div class="item item1 active">
<img src="http://dreamatico.com/data_images/car/car-1.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
<div class="item item2">
<img src="http://dreamatico.com/data_images/car/car-8.jpg" class="img-responsive" />
<div class="details flex-row">
<div class="fix-flex">
<h2>I'm a header title</h2>
<p class="sub-title">
I'm a little sub-title
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<ol class="carousel-indicators">
<li data-target="#main-slider" data-slide-to="0" class="active"></li>
<li data-target="#main-slider" data-slide-to="1"></li>
</ol>
CSS:
.item {
position: relative;
.details {
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
padding: 25px;
color: #fff;
z-index: 2;
align-items: flex-end;
justify-content: center;
h2 {
margin-top: 0;
}
}
&.item2 {
.details {
align-items: flex-start;
justify-content: flex-start;
}
}
}
.flex-row {
display: flex;
flex-flow: row nowrap;
}