通过 safari 查看的网站元素重新定位,适用于其他浏览器

问题描述 投票:0回答:0

以下链接准确无误,与所附图片相符。如下所述可以进行复制。

我正在使用 HTML、CSS 和 JavaScript 开发一个网站:https://github.com/nkozlo3/PortfolioWebsite.git 网站:https://nkozlo3.github.io/PortfolioWebsite/

该网站在 Chrome、Firefox 和 Microsoft Edge 上看起来正确。同样在不同尺寸的笔记本电脑上:Chrome view 1Microsoft Edge view 1 Firefox 视图是一样的。

但是当通过 Safari 查看时,元素会像这样重新定位自己: Safari view 1

要重现问题,只需通过上面的链接访问 Safari 上的网站,或者从我的 GitHub(上面的链接)中提取代码并通过 Safari 运行它。

我试着把这个包装器放在我的 HTML 主体周围

<div id="wrapper" style="margin-left: auto; margin-right: auto; width: 960px">

并添加此元标记

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

我原以为这会强制内容在设备和网站上保持在正确的位置,但它并没有解决 Safari 上的问题。

我还尝试将以下 reset.css 文件添加到我的 style.css 文件中以在不同浏览器之间进行规范化。这也没有解决 Safari 上的问题:

/***
    The new CSS reset - version 1.8.2 (last updated 23.12.2022)
    GitHub page: https://github.com/elad2412/the-new-css-reset
***/

/*
    Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
    - The "symbol *" part is to solve Firefox SVG sprite bug
 */
*:where(:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)) {
    all: unset;
    display: revert;
}

/* Preferred box-sizing value */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Reapply the pointer cursor for anchor tags */
a, button {
    cursor: revert;
}

/* Remove list styles (bullets/numbers) */
ol, ul, menu {
    list-style: none;
}

/* For images to not be able to exceed their container */
img {
    max-inline-size: 100%;
    max-block-size: 100%;
}

/* removes spacing between cells in tables */
table {
    border-collapse: collapse;
}

/* Safari - solving issue when using user-select:none on the <body> text input doesn't working */
input, textarea {
    -webkit-user-select: auto;
}

/* revert the 'white-space' property for textarea elements on Safari */
textarea {
    white-space: revert;
}

/* minimum style to allow to style meter element */
meter {
    -webkit-appearance: revert;
    appearance: revert;
}

/* preformatted text - use only for this feature */
pre {
    all: revert;
}

/* reset default text opacity of input placeholder */
::placeholder {
    color: unset;
}

/* remove default dot (•) sign */
::marker {
    content: "";
}

/* fix the feature of 'hidden' attribute.
   display:revert; revert to element instead of attribute */
:where([hidden]) {
    display: none;
}

/* revert for bug in Chromium browsers
   - fix for the content editable attribute will work properly.
   - webkit-user-select: auto; added for Safari in case of using user-select:none on wrapper element*/
:where([contenteditable]:not([contenteditable="false"])) {
    -moz-user-modify: read-write;
    -webkit-user-modify: read-write;
    overflow-wrap: break-word;
    -webkit-line-break: after-white-space;
    -webkit-user-select: auto;
}

/* apply back the draggable feature - exist only in Chromium and Safari */
:where([draggable="true"]) {
    -webkit-user-drag: element;
}

/* Revert Modal native behavior */
:where(dialog:modal) {
    all: revert;
}

html css
© www.soinside.com 2019 - 2024. All rights reserved.