


The code highlighting problem under Safari browser: What is the reason for the invalidation of the ``` tag combined with `white-space: pre` attribute?
Apr 05, 2025 pm 03:12 PMSafari browser code highlighting problem and solution
In web development, in order to clearly display code snippets and retain their formatting and indentation, it is usually used<code><code>標簽結(jié)合<code><pre class="brush:php;toolbar:false"></pre>標簽,并設(shè)置<code>white-space: pre CSS屬性。然而,Safari瀏覽器在處理包含<script>標簽且文本較長的代碼片段時,可能會忽略<code>white-space: pre屬性,導致代碼換行,破壞原有格式。</script>
例如,如下代碼在Safari瀏覽器中,“#imports”可能會被換行顯示:
<script> import { definecomponent } from '#imports'; </script>And simple<code><div> This problem will not occur with the tag:<pre class="brush:php;toolbar:false"><div> hello world</div> // Pre settings can ensure that no line breaks
This means that when the text is labeled (e.g. <script>)包裹時,<code>white-space: pre的有效性會受到影響。</script>
為了解決這個問題,建議使用以下CSS代碼:
pre { white-space: pre-wrap; /* CSS3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5 */ -moz-binding: url('./wordwrap.xml#wordwrap'); /* 需要配合wordwrap.xml文件使用 */ }
這段代碼使用了多種<code>white-space屬性值和<code>word-wrap屬性,以確??鐬g覽器兼容性,并允許文本在必要時換行,從而避免Safari瀏覽器中<code>white-space: pre失效的問題。請注意,<code>-moz-binding部分需要配合相應(yīng)的<code>wordwrap.xml文件,本文未提供該文件內(nèi)容。 使用<code>pre-wrap允許文本換行,同時保留空格和換行符。
The above is the detailed content of The code highlighting problem under Safari browser: What is the reason for the invalidation of the ``` tag combined with `white-space: pre` attribute?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

First, download the Binance App through the official channel to ensure security. 1. Android users should visit the official website, confirm that the URL is correct, download the Android installation package, and enable the "Allow to install applications from unknown sources" permission in the browser. It is recommended to close the permission after completing the installation. 2. Apple users need to use a non-mainland Apple ID (such as the United States or Hong Kong), log in to the ID in the App Store and search and download the official "Binance" application. After installation, you can switch back to the original Apple ID. 3. Be sure to enable two-factor verification (2FA) after downloading and keep the application updated to ensure account security. The entire process must be operated through official channels to avoid clicking unknown links.

Backdrop-filter is used to apply visual effects to the content behind the elements. 1. Use backdrop-filter:blur(10px) and other syntax to achieve the frosted glass effect; 2. Supports multiple filter functions such as blur, brightness, contrast, etc. and can be superimposed; 3. It is often used in glass card design, and it is necessary to ensure that the elements overlap with the background; 4. Modern browsers have good support, and @supports can be used to provide downgrade solutions; 5. Avoid excessive blur values and frequent redrawing to optimize performance. This attribute only takes effect when there is content behind the elements.

Ouyi is a world-leading digital asset trading platform, providing users with safe, stable and reliable digital asset trading services, and supports spot and derivative transactions of various mainstream digital assets such as Bitcoin (BTC), Ethereum (ETH). Its strong technical team and risk control system are committed to protecting every transaction of users.

Ethereum is a decentralized open source platform based on blockchain technology, which allows developers to build and deploy smart contracts and decentralized applications. Its native cryptocurrency is Ethereum (ETH), which is one of the leading digital currencies with market value in the world.

When using Yandex to find the official Binance channel, you must accurately locate the official website by searching for "Binance Official Website" or "Binance Official Website"; 2. After entering the official website, find the "Download" or "App" entrance in the header or footer, and follow the official guidelines to download or obtain the officially verified installation files through the app store; 3. Avoid clicking on advertisements or third-party links throughout the process, ensure that the domain name is correct and the link is trustworthy, so as to ensure the download security.

Open Yandex browser; 2. Search for "Binance Official Website" and enter the official website link with "binance"; 3. Click the "Download" or mobile phone icon on the page to enter the download page; 4. Select the Android version; 5. Confirm the download and obtain the installation file package; 6. After the download is completed, click on the file and follow the prompts to complete the installation; you must always download through the official channel to avoid malware, pay attention to application permission requests, and regularly update the application to ensure security. The entire process requires careful identification of the official website and reject suspicious links, and finally successfully install the Binance app.

Define@keyframesbouncewith0%,100%attranslateY(0)and50%attranslateY(-20px)tocreateabasicbounce.2.Applytheanimationtoanelementusinganimation:bounce0.6sease-in-outinfiniteforsmooth,continuousmotion.3.Forrealism,use@keyframesrealistic-bouncewithscale(1.1

Android users need to download the installation package through official channels, enable the "Allow to install applications from unknown sources" permission before completing the installation; 2. Apple users need to use Apple IDs in mainland China to log in to the App Store and search for "OKX" to download the official application. After installation, they can switch back to the original account; 3. Always download and keep the application updated through official channels, beware of phishing websites and false applications to ensure the security of accounts and assets.
