Reputation: 453
Currently trying to switch between a 2 column paragraph to a single column paragraph when the browser window width is <769px and >1040px. I'm using column-count to automatically split the text into 2 columns and it works consistently on Chrome and Firefox and almost as well on Safari.
While testing, I found a bug on Safari 14.1+ wherein if you resize the browser from >1040px to 768px, the div containing the text expands for some reason and when you resize it back to >1040px, the issue persists.
Here is an example code
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
.border {
border: 1px solid red;
}
@media only screen and (min-width: 769px){
.columns-md {
column-count: 2;
column-gap: 2rem;
min-height: initial;
}
}
@media only screen and (min-width: 1041px) {
.columns-off-lg {
column-count: 1;
column-gap: initial;
min-height: 0;
}
}
</style>
<body>
<div class="border">
<div class="columns-md columns-off-lg">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum</p>
</div>
</div>
</body>
</html>
Other things I've noticed:
My machine is currently running Big Sur and Safari 14.1.
Any idea if this is just a Safari issue or my CSS?
P.S. I can also confirm others were able to recreate the the bug.
Upvotes: 4
Views: 2214
Reputation: 453
.safari-wrapping-fix {
display: inline-block;
white-space: nowrap;
}
Add the above css to a span element before your closing "p" tag. This solved the issue for us.
Example:
<p>Lorem Ipsum <span class="safari-wrapping-fix"></span></p>
Upvotes: 6
Reputation: 83
I can confirm that it is a Safari issue. I am running through a very similar issue on my own project. When refreshing the browser, the layout will look correctly, it is only when I resize that notice the issue, also toggling between CSS properties inside the browser inspector will solve the issue instantly, only when I resize that the problem appears again. And it is only happening for Safari 15 and Big Sur.
Upvotes: 2