flex properties not working on safari - html

I am using flex for making a searchbar/input element stay centered and change width as the screen size changes.
This is my html:
<div class="flex-container">
<div class="flex-row">
<h1 class="brandname">Hello</h1>
</div>
<div class="flex-row">
<form>
<!-- <div class="search centered"> -->
<div class="search">
<div class="input-container">
<input type="text" name="query" class="searchbar" />
<button type="submit" class="search-button">Search</button>
</div>
</div>
</form>
</div>
</div>
and this is my css:
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.flex-container{
display: flex;
display: -webkit-flex;
align-items: center;
-webkit-align-items: center;
justify-content: center;
-webkit-justify-content: center;
-webkit-flex-direction: row;
flex-direction: row;
flex-wrap: wrap;
-webkit-flex-wrap: wrap;
}
.flex-row {
display: flex;
display: -webkit-flex;
justify-content: center;
-webkit-justify-content: center;
flex: 1;
-webkit-flex: 1;
}
form{
display: flex;
display: -webkit-flex;
justify-content: center;
-webkit-justify-content: center;
flex: 1;
-webkit-flex: 1;
}
.search{
display: flex;
display: -webkit-flex;
flex: 0 1 455px;
-webkit-flex: 0 1 455px;
}
.input-container{
display: flex;
display: -webkit-flex;
flex: 1;
-webkit-flex: 1;
min-width: 0;
}
.searchbar{
flex: 1;
-webkit-flex: 1;
min-width: 0;
}
.flex-container > .flex-row:first-child{
flex: 0 1 100%;
-webkit-flex: 0 1 100%;
}
.brandname {
position: relative;
font-size: 500%;
font-family: 'Lato', sans-serif;
color: #1f0e3e;
text-align: center;
margin-bottom: 30px;
margin-top: 5%;
}
body {
margin: 10px;
}
.input-container{
/*float: left;*/
/*display: block;*/
flex: 1;
-webkit-flex: 1;
outline-style: solid;
outline-color: #e3e3e3;
outline-width: 1px;
}
.searchbar{
margin-left: 5px;
}
.search button {
background-color: rgba(152,111,165,0.38);
background-repeat:no-repeat;
border: none;
cursor:pointer;
border-radius: 0px;
/*overflow: hidden;*/
outline-width: 1px;
outline-style: solid;
outline-color: #e3e3e3;
color: white;
}
.search input{
outline-width: 0px;
outline-style: none;
border-width: 0px;
}
and it works in chrome, ie edge and in this fiddle, but not in safari.
In Safari the searchbar goes above the .brandname element and to the right of it and takes a width of 150px.
any ideas on how to make this work in safari?
One thing that is not working is the the first flex row width of 100% is not working. In safari it is making the two felx-row elements be right next to each other and both of them together are taking 100% of the width.

I changed .flex-row css rules to:
.flex-row {
display: flex;
display: -webkit-flex;
justify-content: center;
-webkit-justify-content: center;
flex: 1;
-webkit-flex: 0 1 100%;
}
and changed the flex-row first child css rules to:
.flex-container > .flex-row:first-child{
flex: 0 1 100%;
-webkit-flex: 0 1 auto;
}
and then it works.
I thought about doing this after reading that flex-wrap is buggy in safari from this SO question which suggests that setting flex-wrap in safari is buggy

Always use the non-prefixed setting last in your CSS rules. In your first rule that would be:
.flex-container{
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
similar for all other rules.

Related

Why is a new line NOT starting after a flexbox is completed?

I'm learning how to utilize flex and just started running into issues for after the flexbox is completed...
#initial {
display: flex;
flex: 1;
justify-content: space-evenly;
align-items: center;
width: 1200px;
margin-left: auto;
margin-right: auto;
border: 1px solid white;
}
#initial .menu {
display: flex;
flex: 1;
justify-content: space-evenly;
align-items: center;
margin: 15px auto 15px auto;
width: 1100px;
border: 1px solid rgba(245, 245, 245, 0.699);
border-radius: 50px;
line-height: 2rem;
font-size: 1.1rem;
overflow: hidden;
}
#initial .menu .menuItem {
display: flex;
flex: 1;
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
text-align: center;
flex-direction: column;
flex-wrap: wrap;
align-content: space-around;
justify-content: space-evenly;
}
#initial .menu .menuItem:hover {
background-color: #FDB000;
color: black;
cursor: pointer;
display: flex;
flex: 1;
text-align: center;
flex-direction: column;
flex-wrap: wrap;
align-content: space-around;
justify-content: space-evenly;
}
<div id="initial">
<div class="menu">
<div id="initialMenuHeader" class="menuItem" onclick="menuCollapsable(this)">Δ</div>
<div id="initialMenuHVQ" class="menuItem" onclick="initialHVQ()">Hivecoin</div>
<div id="initialMenuRVN" class="menuItem" onclick="initialRVN()">Ravencoin</div>
<div id="initialMenuAVN" class="menuItem" onclick="initialAVN()">Avian</div>
</div>
<div class="body">
<h1>NAME OF POOL GOES HERE</h1>
<p class="intro">¡Intro crap will go here!</p>
</div>
</div>
As it stands, my .menu looks like this. Please note that the image is uncensored and includes expletives
Everything I could find online suggests that when the flex-box is completed, it should go back to the normal flow (e.g. not floating).
Please let me know what I'm doing wrong and/or missing.
JSFiddle of my code (added some things that I didn't include above like body for background-color and color
Since you make #initial as flex, and by default flex-direction set to row your menu align with with your body. If your want menu & body in 2 lines add below css:
#initial{
flex-direction: column;
}

My three column responsive layout is not respecting flex order

I want to make a three columns layout for my website using flexboxes.
However, my 'commentCaMarche' div does not seem to follow the flex order, it is located at the top of the 'details-index' column. Do you know how to solve this problem?
#credits {
font-family: 'Roboto Condensed', sans-serif;
color: #FFFFFF;
height: 100vh;
background-color: #FB3D00;
margin-bottom: 0;
}
#columns {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
#details-index {
font-size: 1.6vmin;
text-align: center;
flex: 1;
order: 1;
display: flex; /*Note : Each of my columns is also a flex container for other contents I omitted*/
flex-direction: column;
justify-content: space-around;
}
(...)
#commentCaMarche {
font-size: 2vmin;
text-align: center;
flex: 1;
order: 2;
display: flex;
flex-direction: column;
justify-content: space-around;
}
(...)
#sources {
font-size: 1.4vmin;
text-align: center;
flex: 1;
order: 3;
display: flex;
flex-direction: column;
justify-content: space-around;
}
<div id='credits'>
<div id='columns'>
<div id='commentCaMarche'>
<h2>Comment ça marche</h2> (...)
</div>
<div id='details-index'>
<h2>Le détail</h2> (...)
</div>
<div id='sources'>
<h2>Sources des données</h2> (...)
</div>
</div>
</div>
Here is the css for making it responsive 3 column
#columns{width:100%; float:left;}
#commentCaMarche{width:33.33%; float:left}
#details-index{width:33.33%; float:left}
#sources{width:33.33%; float:left}
You need to change order property for your flex columns. JSfiddle
#details-index {
font-size: 1.6vmin;
text-align: center;
flex: 1;
order: 2;
display: flex; /*Note : Each of my columns is also a flex container for other contents I omitted*/
flex-direction: column;
justify-content: space-around;
}
#commentCaMarche {
font-size: 2vmin;
text-align: center;
flex: 1;
order: 1;
display: flex;
flex-direction: column;
justify-content: space-around;
}
The flex-wrap: wrap will make your columns break line when they doesn't fit the width available, so by removing it from the columns rule, you'll have 3 proper columns at any width.
I also temporarily removed the order from the flex items, so they show up in the same order they are placed in the markup, but if you need to change them like in your sample, please add it back, or why not simply swap them in the markup
#credits {
font-family: 'Roboto Condensed', sans-serif;
color: #FFFFFF;
height: 100vh;
background-color: #FB3D00;
margin-bottom: 0;
}
#columns {
display: flex;
justify-content: space-between;
}
#details-index {
font-size: 1.6vmin;
text-align: center;
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-around;
}
#commentCaMarche {
font-size: 2vmin;
text-align: center;
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-around;
}
#sources {
font-size: 1.4vmin;
text-align: center;
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-around;
}
<div id='credits'>
<div id='columns'>
<div id='commentCaMarche'>
<h2>Comment ça marche</h2>
(...)
</div>
<div id='details-index'>
<h2>Le détail</h2>
(...)
</div>
<div id='sources'>
<h2>Sources des données</h2>
(...)
</div>
</div>
</div>

How to break words with IE 11 running on WP 8.1?

I'm struggling to get word-wrap: break-word; to work on Nokia Lumia 930 (and probably other Windows phones). Any ideas? The text just floats over to the next tab.
It seems to be working ok in iOS and Android.
body {
background: lightblue;
}
.container {
width: 320px;
margin: 20px auto;
border: 1px solid #ebebeb;
background: white;
}
.tabs {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.tab {
width: 25%;
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
border-right: 1px solid #ebebeb;
}
.tab:last-child {
border-right: none;
}
.label {
display: block;
margin: auto 0;
text-align: center;
word-wrap: break-word;
}
<div class="container">
<div class="tabs">
<div class="tab">
<span class="label">xxxxxx xxx xxxxxxxxxx</span>
</div>
<div class="tab">
<span class="label">xxxxxx xx xxxxx</span>
</div>
<div class="tab">
<span class="label">xxxx xxxxxx</span>
</div>
<div class="tab">
<span class="label">xxxxxx xx</span>
</div>
</div>
</div>
Adding align-self: stretch to .label solves it.
.label{
align-self: stretch
}

Flex Gridlayout with flex-direction row and different heights of row

I need a flex grid, where each grid cell has equal width, after every second cell it should wrap. But some cells should have full width. So far no problem.
But I want some of these cells have a fixed height.
In my example I want the blue background to be hidden and filled by the cells below the first one. Is this possible without adding more html tags?
The outcome should look like the second box, but without the additional html tag.
.flex-container {
background-color: blue;
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-flex-direction: row;
flex-direction: row;
width: 300px;
height: 300px;
border: red 5px solid;
}
.flex-item {
background: tomato;
width: 50%;
color: white;
font-weight: bold;
font-size: 2em;
text-align: center;
border: green 1px solid;
box-sizing: border-box;
}
.flex-item:first-child {
width: 100%;
height: 50px;
}
.flex-container2 {
background-color: blue;
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-flex-direction: row;
flex-direction: row;
width: 300px;
height: 300px;
border: red 5px solid;
}
.flex-item2 {
background: tomato;
width: 100%;
color: white;
font-weight: bold;
font-size: 2em;
text-align: center;
border: green 1px solid;
box-sizing: border-box;
height: 50px;
}
.additional-flex-container {
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-flex-direction: row;
flex-direction: row;
width: 100%;
height: calc(100% - 50px);
flex-grow: 1;
}
.additional-flex-container .flex-item2 {
background: tomato;
width: 50%;
color: white;
font-weight: bold;
font-size: 2em;
text-align: center;
border: green 1px solid;
box-sizing: border-box;
height: auto;
}
<div class="flex-container">
<div class="flex-item">1</div>
<div class="flex-item">2</div>
<div class="flex-item">3</div>
<div class="flex-item">4</div>
<div class="flex-item">5</div>
</div>
<hr/>
<div class="flex-container2">
<div class="flex-item2">1</div>
<div class="additional-flex-container">
<div class="flex-item2">2</div>
<div class="flex-item2">3</div>
<div class="flex-item2">4</div>
<div class="flex-item2">5</div>
</div>
</div>
The only possibility I found was to calculate the height of all items. It is not as flexible as I want it, but I can play around at least with some additional classes.
.flex-container {
background-color: blue;
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-flex-direction: row;
flex-direction: row;
width: 300px;
height: 300px;
border: red 5px solid;
}
.flex-item {
background: tomato;
width: 50%;
color: white;
font-weight: bold;
font-size: 2em;
text-align: center;
border: green 1px solid;
box-sizing: border-box;
height: calc((100% - 50px) / 2);
}
.flex-item:first-child {
width: 100%;
height: 50px;
}
<div class="flex-container">
<div class="flex-item">1</div>
<div class="flex-item">2</div>
<div class="flex-item">3</div>
<div class="flex-item">4</div>
<div class="flex-item">5</div>
</div>

Creating divs displaying inside each other and inline using CSS

I have started on this fiddle using CSS:
.cont {
border:1px solid #F36F25;
}
.ticketnumber {
display:inline-block;
}
.status {
display:inline-block;
}
.summary {
display:inline-block;
float:left;
}
.last_updated {
display:inline-block;
float:right;
}
.box {
}
http://jsfiddle.net/3qbn222u/
i want to create something that looks like this image:
how can i achieve this in the easiest way?
//HTML BLOCK
<div class="cont">
<div class="header_box">
<div class="ticket_box">
<div class="ticketnumber">ID#0000001234</div>
<div class="summary">Subject: Grumpy Cat</div>
<div class="summary">Summary: blaahh</div>
</div>
<div class="summary_box">
<div class="last_updated">10 minutes ago</div>
<div class="status"></div>
</div>
</div>
<div class="wrapper_box">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</div>
//CSS BLOCK
.cont {
display: flex;
display: -webkit-flex;
height: 200px;
border-radius: 5px;
flex-direction: column;
-webkit-flex-direction: column;
border: 1px solid #dddddd;
box-shadow: 0 1px 5px rgba(0,0,0,.6);
-webkit-box-shadow: 0 1px 5px rgba(0,0,0,.6);
}
.header_box{
display: flex;
display: -webkit-flex;
flex: 1;
-webkit-flex: 1;
font-size: 12px;
}
.wrapper_box{
display: flex;
display: -webkit-flex;
flex: 2;
-webkit-flex: 2;
}
.ticket_box{
display: flex;
display: -webkit-flex;
flex: 6;
-webkit-flex: 6;
flex-direction: column;
-webkit-flex-direction: column;
justify-content: center;
-webkit-justify-content: center;
align-items: flex-start;
-webkit-align-items: flex-start;
margin: 10px 10px;
}
.summary_box{
display: flex;
display: -webkit-flex;
flex: 4;
-webkit-flex: 4;
flex-direction: column;
-webkit-flex-direction: column;
justify-content: center;
-webkit-justify-content: center;
align-items: flex-end;
-webkit-align-items: flex-end;
margin: 10px 10px;
}
.ticketnumber {
display: flex;
display: -webkit-flex;
}
.summary {
display: flex;
display: -webkit-flex;
}
.last_updated {
display: flex;
display: -webkit-flex;
}
.status {
display: flex;
display: -webkit-flex;
height: 15px;
width: 15px;
margin: 10px 0px;
border-radius: 50%;
background: red;
}
.box {
display: flex;
display: -webkit-flex;
flex: 1;
-webkit-flex: 1;
justify-content: center;
-webkit-justify-content: center;
align-items: center;
-webkit-align-items: center;
border: 10px solid #f3f3f3;
margin: 5px 5px;
background: #ccc;
background: url(http://www.freeallimages.com/wp-content/uploads/2014/09/grumpy-cat-no-1.jpg) no-repeat;
background-size: cover;
-webkit-background-size: cover;
background-position: center;
-webkit-background-position: center;
color: #fff;
}
Agreed using FlexBox would be the easiest way.
Here is a good reference guide to FlexBox:
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes