Expand flexbox child into full new row wider than container - css

I'm creating a portfolio section working with Bootstrap 4 and learning flexbox. Each portfolio item initially contains a thumbnail that expands/collapses with more details when clicked.
At full width, the items run in rows of 4 columns. Can I use flexbox to get the detailed description (pabout) to expand below the current row and run full width? i.e. On mobile, items will be in 1 column and clicking an item will expand the description below the item clicked. At larger widths, the description will expand (to make a new row) below the row at full width.
Looking for the CSS for the expanded row. I can manage the JS.
<section id="test" class="container">
<div class="flex-container">
<div class="pitem">
<div class="pcard">
<p>Title 1</p>
</div>
<div class="pabout">
Detailed description goes here
</div>
</div>
<div class="pitem">
<div class="pcard">
<p>Title 2</p>
</div>
<div class="pabout collapse">
Detailed description goes here
</div>
</div>
<div class="pitem">
<div class="pcard">
<p>Title 3</p>
</div>
<div class="pabout collapse">
Detailed description goes here
</div>
</div>
<div class="pitem">
<div class="pcard">
<p>Title 4</p>
</div>
<div class="pabout collapse">
Detailed description goes here
</div>
</div>
</div>
</section>
Update:
Here's some CSS/HTML I'm working with. I don't mind if either the description div expands to the full viewport width or the Bootstrap container bounds.
https://codepen.io/codecarson/pen/zEPXge

Changing last item's flex-grow :
.flex-item {
background: tomato;
padding: 5px;
width: 200px;
height: 150px;
margin: 10px;
color: white;
font-weight: bold;
font-size: 3em;
text-align: center;
//This change
&:last-child{
flex-grow: 5;
}
}
Seems to work as brute force method. Or are you searching for something more intelligent ?

Related

Layout issues with spans and Bootstrap 3

TB3 here. Here is the respective jsFiddle. I am trying to build a little minitron (mini jumbotron) that has the following layout:
As you can see, there is a main <div> given the minitron class. Each 'minitron' has:
An icon (Glyphicon)
A name
A description
A 'Learn More' button
Unfortunately my CSS-fu is pretty weak, and as you can see in that fiddle, I'm just not achieving the desired layout.
Here's my attempt at some CSS rules:
.minitron-icon {
width:20%;
height: 20%;
margin: 5px;
}
.minitron-name {
font-size: 18px;
}
.minitron-desc {
width: 80%;
margin: 5px;
}
.minitron-learnmore {
width: 95%;
}
Can anyone spot where I'm going awry?
What about this one? https://jsfiddle.net/oh69hq71/17/
Taking advantage of BS grid system using rows and columns. The first row containing the glyphicon and name/description, the other one with the learn more full width.
<div class="well minitron">
<div class="row">
<div class="col-xs-2">
<span class="glyphicon glyphicon-piggy-bank minitron-icon"></span>
</div>
<div class="col-xs-10">
<div class="row">
<span class="minitron-name">Some Name</span>
</div>
<div class="row">
<span class="minitron-desc">A short meaningful description goes here.</span>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<button class="minitron-learnmore btn btn-success" type="button">LEARN MORE ABOUT JUPITER!</button>
</div>
</div>
</div>
*Update:
Increasing glyphicon size: In the glyphicon span set its style as "font-size:1.5em;"
To align it closer to name and description, add the style="text-align:right" at the glyphicon div container
The description is aligned to the named without the original css styles.
To increase padding (or margin) between the learn more button and description/icon, increase the learn more div top margin
New fiddle: https://jsfiddle.net/oh69hq71/18/

Bootstrap background width padding

I'm using Boostrap 3 and have a problem with backgrounds on elements that appear too wide. The container is in desktop mode 1170px and has 15px padding left and right which makes the content appear with 1140px width.
When I'm adding an element with a different background color (let's say body + .container both has same background), then the element will appear as 1170px wide due to the background showing in the padding area as well.
I could add CSS for each element with deviating background in each screen width (media queries) to solve the problem. But I hope there is a better way to achieve this since I can't be the only person with this problem. Does anyone know some Boostrap class / function to solve this issue, or know some best practise for this?
Try wrapping the rows and/or inner content, you can see how I have done it here; http://jsfiddle.net/w7wowg94/
HTML
<div id="master-wrap">
<div class="container">
<div class="wrap-class-one">
<div class="row">
<div class="col-md-6">Content 1</div>
<div class="col-md-6">Contnent 2</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-4">
<div class="inner-wrap">Content 1</div>
</div>
<div class="col-md-4">
<div class="inner-wrap">Contnent 2</div>
</div>
<div class="col-md-4">
<div class="inner-wrap">Contnent 2</div>
</div>
</div>
</div>
</div>
CSS
#master-wrap {
margin: 0 auto;
background-color: #eee;
padding: 15px;
}
.wrap-class-one {
background-color: #ccc;
padding: 15px;
}
.inner-wrap {
padding: 15px;
background-color: #ccc;
}

Creating a fixed footer with Bootstrap

I am building an app that uses Bootstrap. I want this app to have a footer. The footer needs to "stick" to the bottom. In other words, if the content is larger than the height of the screen, the footer should still be visible, the content goes under it. If the content takes less than the height of the screen, I still need the footer to stick tothe bottom. I tried using the sticky footer. However, that doesn't work. Currently, I am trying the following:
Here's My Plunker
My HTML looks like this:
<div class="footer">
<div class="container text-center">
<button class="btn btn-warning"><span class="glyphicon glyphicon-filter"></span></button>
<button class="btn btn-warning"><span class="glyphicon glyphicon-th"></span></button>
</div>
</div>
How do I build a footer that permanently sticks to the bottom? I'm basically trying to build an "action bar" that is visible only when the site runs on a phone.
Thank you for your help.
use the following code
.footer {
background-color: #f5f5f5;
bottom: 0;
height: 60px;
position: fixed;
width: 100%;
}
you should change the footer position :
.footer {
background-color: #f5f5f5;
bottom: 0;
height: 60px;
position: fixed; /*change it*/
width: 100%;
}
Bootstrap comes with its nav elements ready to roll as a footer.
Simply create your element and add these classed navbar navbar-default navbar-fixed-bottom.
<footer>
<div class="navbar navbar-default navbar-fixed-bottom" id="footer">
<div class="container">
<p>this is your footer that sticks to the bottom</p>
</div>
</div>
</footer>
You can then expand on this by splitting the containing div into blocks with something like
<div class="row">
<div class="row">
<div class="col-xs-8 col-sm-6">
Level 2: .col-xs-8 .col-sm-6
</div>
<div class="col-xs-4 col-sm-6">
Level 2: .col-xs-4 .col-sm-6
</div>
</div>
</div>
the above would go inside the container div
as shown here http://jsfiddle.net/showcaseimagery/5y14pqgv/

How to achieve 4 columns of content, all content bunched up?

Apologies for the rather odd title question, it's a difficult one to explain. I'm attempting to create a WordPress that uses two columns, side by side, to display content from the same loop. The effect I'd like to achieve would be formatted like this:
http://itsmeifrah.tumblr.com/
Only with text posts and not images. I'm stumped on how to do this, though. I've tried floating all div's left and assigning them each the same width, but this causes content to be misaligned when some posts are longer than others. Plus, this is for dynamically created content, so I have to figure a solution that's WordPress loop-friendly. In order to help illustrate this issue, I've drawn the following rather crude png:
http://s13.postimage.org/yoo4z9g9z/content_misaligned.png
Please help!
You must create columns and then put your content.
HTML:
<div class="multi_col">
<div class="col">
<div class="item">
Item 1
</div>
<div class="item">
Item 2
</div>
<div class="item">
Item 3
</div>
</div>
<div class="col">
<div class="item">
Item 1
</div>
<div class="item">
Item 2
</div>
</div>
</div>
CSS:
.mutlti_col
{
width: 420px;
}
.col
{
float: left;
width: 200px;
margin-left: 10px;
}
.item
{
width: 200px;
margin-top: 10px;
}
​
Please check jsfiddle.

divide screen into equal parts with overflow

I recently made a website where I needed 6 columns with the y overflow visible. I couldn't make a clean 6 divisions. The width needed to be wider to adjust for the 6 scrollbars and a bit of padding.
Is there a better way than my attempt?
<div class="col">
<div class="section">
Content that overflows this section.
</div>
</div>
.col {
width: 15.2%;
padding-right: 15px;
float: left;
}
.section {
overflow-y: scroll;
width: 100%;
}
It's very sloppy and the columns don't reach the far right edge.
I don't know jquery well enough to attempt but will like take any advice.
****** I worked it out, so silly. You need to use % for everything including padding. Duh ******* Sorry for wasting anyones time!
I would say that it is better to set padding for the inner div .section, so there will be no need to adjust .col width.
Try this HTML code:
<div id="grid">
<div class="col">
<div class="section">
Content that overflows this section.
</div>
</div>
<div class="col">
<div class="section">
Content that overflows this section.
</div>
</div>
<div class="col">
<div class="section">
Content that overflows this section.
</div>
</div>
<div class="col">
<div class="section">
Content that overflows this section.
</div>
</div>
<div class="col">
<div class="section">
Content that overflows this section.
</div>
</div>
<div class="col">
<div class="section">
Content that overflows this section.
</div>
</div>
</div>
With this CSS:
#grid {
margin-left: -15px;
}
.col {
width: 16.6%;
float: left;
}
.section {
overflow-y: scroll;
margin-left: 15px;
height: 100px;
background: green;
}​
Please note that #grid { margin-left: -15px; } will help you get rid of unnecessary white space before first column
take a look at Live demo

Resources