简体   繁体   中英

Why does my website shift to the left on Safari?

我的网站在 Safari 上的屏幕截图

You are able to visit my website at here

This happens when I add this CSS styling:

.container {
  margin-inline: auto;
  width: min(90%, 70.5rem);
}

The reason i add this container is to restrict my contents from expanding when someone opens the website in a very large screen. This works fine with other browsers. Any help would be appreciated thank you.

MDN Web Docs: The margin-inline CSS shorthand property is a shorthand property that defines both the logical inline start and end margins of an element, which maps to physical margins depending on the element's writing mode, directionality, and text orientation.

According to MDN web docs, Safari does not support margin-inline.

在此处输入图像描述

Try to use margin: 0 auto

For more information you can visit: https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline

margin-inline is not supported by Safari, IOS Safari or Edge see so it probably isn't safe to rely on it given the ubiquity of Safari and the increasing use of Edge.

See https://caniuse.com/?search=margin-inline

Some other way of centering things on large screens will need to be used. Perhaps the more traditional left: 50% and transform: translateX(-50%) would help?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM