I have following code, that works well in Chrome and FireFox but doesn't work in Safari.
Could you please help me investigate what is going on and how do I make it compatible for Safari and other browsers?
Chrome:
Safari:
LESS:
body {
margin-top: 30px;
}
.time-slice {
position: relative;
display: flex;
align-items: stretch;
margin-left: 20px;
> * {
padding: 20px;
}
}
.circle {
width: 16px;
height: 16px;
box-sizing: content-box;
border-color: #29a8bb;
background: #ffffff;
border-radius: 32px;
display: block;
border: 2px solid blue;
}
.circle-wrap {
position: absolute;
top: 0px;
left: 91px;
z-index:2;
> .circle {
position: relative;
left: 20px;
}
}
.date-time {
flex-shrink: 0;
flex-basis: 100px;
text-align: center;
margin-top: -5px;
}
.date,
.time {
max-width: 90px;
color: #999999;
font-size: 13px;
margin-top: 0px;
margin-bottom: 10px;
margin-left: 20px;
}
.time-slice.row:not(:last-child) .point-title {
border-left: 2px solid blue;
padding-left: 15px;
padding-top:0;
position:relative;
top:20px;
}
.duration {
margin-left: 50px;
max-width: 90px;
color: #999999;
font-size: 13px;
margin-top: -15px;
margin-bottom: 10px;
}
HTML:
<div class="timeline">
<div class="time-slice row">
<div class="date-time">
<p class="date">Fri 28 Aug</p>
<p class="time">10:00</p>
</div>
<div class="circle-wrap">
<div class="circle"></div>
</div>
<div class="point-title">
<span>
<b>Kiev Borispol (KBP)</b>
</span>
</div>
</div>
<div class="time-slice row">
<div class="date-time">
<p class="time duration">1h 30min</p>
</div>
<div class="point-title">
</div>
</div>
<div class="time-slice row">
<div class="date-time">
<p class="date">Fri 28 Aug</p>
<p class="time">10:00</p>
</div>
<div class="circle-wrap">
<div class="circle"></div>
</div>
<div class="point-title">
<span>
<b>Amsterdam (AMS)</b>
</span>
</div>
</div>
</div>
</div>
Are you using all the correct vendor prefixes?
Prefixed Codepen that works in Chrome, Edge & FF That's usually the problem with Safari.
If you click on the "View Compiled" button you will see the full CSS. Codepen uses a couple of optional tools (autoprefixer or prefixfree) to manage this. Click on the CSS Cog to see the options available
body {
margin-top: 30px;
}
.time-slice {
position: relative;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: stretch;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
margin-left: 20px;
}
.time-slice > * {
padding: 20px;
}
.circle {
width: 16px;
height: 16px;
box-sizing: content-box;
border-color: #29a8bb;
background: #ffffff;
border-radius: 32px;
display: block;
border: 2px solid blue;
}
.circle-wrap {
position: absolute;
top: 0px;
left: 91px;
z-index: 2;
}
.circle-wrap > .circle {
position: relative;
left: 20px;
}
.date-time {
-webkit-flex-shrink: 0;
-ms-flex-negative: 0;
flex-shrink: 0;
-webkit-flex-basis: 100px;
-ms-flex-preferred-size: 100px;
flex-basis: 100px;
text-align: center;
margin-top: -5px;
}
.date,
.time {
max-width: 90px;
color: #999999;
font-size: 13px;
margin-top: 0px;
margin-bottom: 10px;
margin-left: 20px;
}
.time-slice.row:not(:last-child) .point-title {
border-left: 2px solid blue;
padding-left: 15px;
padding-top: 0;
position: relative;
top: 20px;
}
.duration {
margin-left: 50px;
max-width: 90px;
color: #999999;
font-size: 13px;
margin-top: -15px;
margin-bottom: 10px;
}
<div class="timeline">
<div class="time-slice row">
<div class="date-time">
<p class="date">Fri 28 Aug</p>
<p class="time">10:00</p>
</div>
<div class="circle-wrap">
<div class="circle"></div>
</div>
<div class="point-title">
<span>
<b>Kiev Borispol (KBP)</b>
</span>
</div>
</div>
<div class="time-slice row">
<div class="date-time">
<p class="time duration">1h 30min</p>
</div>
<div class="point-title">
</div>
</div>
<div class="time-slice row">
<div class="date-time">
<p class="date">Fri 28 Aug</p>
<p class="time">10:00</p>
</div>
<div class="circle-wrap">
<div class="circle"></div>
</div>
<div class="point-title">
<span>
<b>Amsterdam (AMS)</b>
</span>
</div>
</div>
</div>
</div>
Safari needs the -webkit
prefix for all flex properties. Try adding this to the css:
.time-slice {
display: -webkit-flex;
-webkit-align-items: stretch;
}
.date-time {
-webkit-flex-shrink: 0;
-webkit-flex-basis: 100px;
}