I have two boxes within each of my member's profile page on my forum that I would like to switch.
Screenshot:
http://s22.postimg.org/69aqe1i29/panel.jpg
I want the "About" section below the "My Badges" section
is this possible within just CSS?
direct link to page in question: http://idenitties.com/vanilla/profile/3/test1
Reordering the HTML is your best option. If this is generated content and you're unable to modify it in any way, you can use Flexbox to do reorder them.
http://tinker.io/9d3f8/1
.container {
display: -webkit-box;
display: -moz-box;
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
.about {
-webkit-box-ordinal-group: 2;
-moz-box-ordinal-group: 2;
-webkit-flex-order: 1;
-ms-flex-order: 1;
-webkit-order: 1;
order: 1;
}
<div class="container">
<div class="about">
About (first in source)
</div>
<div class="badges">
Badges (second in source)
</div>
</div>
The up side is that you don't need to know the sizes of either of the elements. The down side is that browser support is limited: IE10, Chrome, Opera, Firefox, Safari
http://caniuse.com/#feat=flexbox
The best way would be to swap the <div> in the HTML but you can use a little absolute positioning to move the divs around.
For example this would work:
.about{
position: absolute;
width: 230px;
bottom: -30px;
}
But I would say the best option would be to just change the ordering in the HTML, simple copy paste.
If box height is constant you may switch them using relative positioning. I mean you may shift top box to down for height of bottom box and otherwise.
.Box.About {
position: relative;
top: 114px;
}
.Box.PeregrineBadgesBox {
position: relative;
top: -178px;
}
Related
I have container with buttons on top of a map control. This control needs to be scrollable as there might be more buttons than the screen height allows for.
What I am looking for is a way to have the buttons to be displayed outside of the container which means that I can put the container off the screen to be invisible.
Or to have the scrollbar on the left hand side so that it is not between the map and the controls.
Here is some html
<div class='ctrl__scroll'>
<button class="map__interface mdl-button mdl-js-button mdl-button--fab mdl-button--colored">
<i class="material-icons">add</i>
</button>
<button class="map__interface mdl-button mdl-js-button mdl-button--fab mdl-button--colored">
<i class="material-icons">remove</i>
</button>
<button>...</button>
</div>
Here is the css
.ctrl__scroll {
position: absolute;
top: 0;
left: 0;
width: 90px;
height: 100%;
overflow-y: auto;
overflow-x: hidden;
background-color: rgba(0, 0, 0, 0.5);
}
.ctrl__scroll > .mdl-button {
margin-top: 10px;
margin-left: 10px;
}
Here is the jsFiddle for the screenshot.
https://jsfiddle.net/goldrydigital/zez3gz21/
Edit: I have now worked this out and changed the jsFiddle. I am using the excellent jScrollPane plugin which allows me to do whatever I want with scrollpanes.
Even if you could display the children outside their scrollable parent (which is counter-intuitive at best) I don't think you'd be able to scroll them. However, you can't have overflow-x:visible; overflow-y:auto; on the same an element. It will automatically add a scrollbar for the X asis too.
Let's take into account that most mobile devices have nice-looking, self-hiding semi-transparent bars, making your solution look good even with the scrollbar visible (as it is now). We only need to fix the scrollbar on non-touch devices. On desktop devices, which are rendering it ugly and opaque. Here's a possible solution:
#media (min-width: 768px) {
.ctrl__scroll > .mdl-button {
margin: 10px 0 0 10px;
}
.ctrl__scroll {
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-moz-box-orient: vertical;
-moz-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-moz-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
overflow: visible;
background-color: transparent;
}
}
Add it at the end of your current CSS. Your updated jsFiddle.
Just add:
.map {
padding-left: 90px;
...
}
which is the size of your side menu
The problem is that in IE10, the width of the columns inside the row is being calculated wrong, it appears to be adding on the width of the column margins (in total 80px), but in Firefox and Chrome it calculates it perfectly and fits everything inside 1260px. The main issue is that i have prefixed everything in what i believe is the right way, but i still get the issue.
You can see it here on jsFiddle - http://jsfiddle.net/andyjh07/ue2zfga6/
CSS:
.row {
width: 100%;
position: relative;
background: red;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
box-orient: vertical;
-webkit-flex-direction: column;
-moz-flex-direction: column;
flex-direction: column;
-ms-flex-direction: column;
margin-bottom: 40px; }
.row:after {
content: "";
display: table;
clear: both; }
.row *[class^="col-"] {
position: relative;
display: block;
height: auto; }
.row *[class^="col-"]:first-child {
margin-left: 0; }
#media (min-width: 64em) {
.row {
box-orient: horizontal;
-webkit-flex-direction: row;
-moz-flex-direction: row;
flex-direction: row;
-ms-flex-direction: row; } }
#media (min-width: 78.75em) {
.row {
max-width: 78.75em;
margin: 0 auto; } }
.col-one-third {
width: 100%;
background: blue; }
#media (min-width: 64em) {
.col-one-third {
width: 33.3%;
margin-left: 40px; } }
.col-two-thirds {
width: 66.7%;
margin-left: 40px;
background: blue; }
How it looks on Chrome, IE11, Firefox
How it looks on IE 10, emulated inside IE11's dev console/tools
As you can see, the margin's are being added and going beyond the width of the container
I don't have IE10 available, but it seems like you should look at caniuse.com and the known issues. Or maybe this user moderated list on Github. Or maybe the comment section of the css-tricks guide.
The caniuse site mentions:
IE10 and IE11 default values for flex are 0 0 auto rather than 0 1 auto, as per the draft spec, as of September 2013.
and
In IE10 and IE11, containers with display: flex and flex-direction: column will not properly calculate their flexed childrens' sizes if the container has min-height but no explicit height property.
The Github site mentions:
When using align-items:center on a flex container in the column direction, the contents of flex item, if too big, will overflow their container in IE 10-11.
Workaround
Most of the time, this can be fixed by simply setting max-width:100% on the flex item. If the flex item has a padding or border set, you'll also need to make sure to use box-sizing:border-box to account for that space. If the flex item has a margin, using box-sizing alone will not work, so you may need to use a container element with padding instead.
This comment on css-tricks shows that where you would normally say flex: 1; you should say -ms-flex: 1 0 auto;
Also, you should change your code where it does something like this:
-webkit-flex-direction: column;
-moz-flex-direction: column;
flex-direction: column;
-ms-flex-direction: column;
to this:
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
You always want the proper line of code—the one without flags— at the bottom of the prefix list.
The CSS3 flexbox, or flex, layout allows to easily center an element horizontally and vertically even when its height and width are unknown.
Can the flex layout be used to absolutely position an overlay (of unknown height and width) in the center of a page?
Elements lose their flex item status if they are absolutely positioned. In order to do what you're suggesting, you need to absolutely position the flex container:
http://codepen.io/cimmanon/pen/prFdm
.foo {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-box-pack: center;
-webkit-box-align: center;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.bar {
margin: auto;
}
<div class="foo">
<div class="bar">Bar</div>
</div>
Note that I've omitted the moz 2009 Flexbox prefixes because absolute positioning breaks flex containers in Firefox. It should just work in Firefox versions with the standard Flexbox properties.
in my case it centered an absolute element. browser: Chrome 56.0
https://codepen.io/MarvinXu/pen/WjprpL
.flexbox {
display: flex;
height: 200px;
align-items: center;
}
.abs {
position: absolute;
right: 0;
}
<div class="flexbox">
<span>inline</span><span class="abs">position:absolute</span>
</div>
I am trying to resize an image to be the width of its parent div; normally width: 100%; works fine, but when the parent has display: box; the img is not resized. Giving the child image box-flex: 1 has no effect.
<div style="display: -webkit-box; -webkit-box-pack: center; width: 100%;">
<img src="foo.jpg" style="-webkit-box-flex: 1;" />
</div>
Maybe you have solved this, but you can use (Providing example for mozilla)
IMAGE {
display: -moz-box;
-moz-box-flex: 1;
}
#cont {
-moz-box-orient: horizontal;
display: -moz-box;
}
Haven't tested the example and in worst case you need to make some tweek, but i'm pretty sure it's correct.
Granted this is an old question, however, it still shows up in searches so wanted to update with an answer:
Currently in Chrome 23 and Firefox Nightly 21.0a1 this layout works to keep the image the size of the parent div and resize (along with keeping it centered).
http://jsfiddle.net/qAErr/
HTML
<section id="holdMe">
<div>
<img src="http://www.w3.org/html/logo/downloads/HTML5_Logo_512.png" alt="html5"/>
</div>
</section>
CSS
#holdMe {
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
}
#holdMe img {
width: 100%;
}
Browser?
I'm not aware of any browser that supports the flexbox spec without vendor prefixes.
display: -moz-box; and display: -webkit-box; etc.
Actually, I just looked at your code again... if you're using flex on the images, you don't need the width declaration since flex defines width dynamically.
You should also define the width of the parent div.
Is there any pure CSS only solution to keep footer fixed at bottom in Mobile Web-kit browsers?
Specially in iPhone and Android browser.
Not really. Those browsers don't actually use scrolling; they lay out the document on an infinite canvas and then pan across it. Which is more or less semantic weasel-wording to say that they don't support position: fixed in practice.
Use flexbox :)
<body>
<div id="mainPart"></div>
<footer></footer>
</body
<style>
body {
display: -webkit-box; -webkit-box-align: stretch; -webkit-box-orient: vertical;
display: -moz-box; -moz-box-align: stretch; -moz-box-orient: vertical;
}
#mainPart { -webkit-box-flex: 1; -moz-box-flex: 1; position: relative; z-index: 2;}
footer{
background-color:#FFC579;
height:50px;
position: relative; z-index: 3;
}
#footer {
position: fixed;
bottom: 0;
}
jsFiddle.
Works since iOS5.