久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 css 復制 html 元素

using css to duplicate html elements(使用 css 復制 html 元素)
本文介紹了使用 css 復制 html 元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我一直在處理我正在嘗試正確實施的網頁設計.此設計包含在整個頁面中部分或全部重復的導航元素 - 特別是,指向主要 3 個導航類別的鏈接在頁面上出現不少于 4 次.

I've been handing a design for a webpage which I'm trying to implement correctly. This design contains navigation elements which are partially or entirely duplicated all over the page - in particular, links to the main 3 categories for navigation are present on the page no less than 4 times.

我不是網頁設計專家,但我不喜歡在 html 中復制相同內容的想法.我可以使用 CSS 以使我的 html 包含一個完整格式的導航鏈接列表,但標準瀏覽器視圖包含多個部分重復項嗎?

I'm no web design expert, but I don't like the idea of having the same content duplicated in the html. Can I use CSS so that my html contains a single list of navigation links in a sane format, but the standard browser view contains multiple partial duplicates?

(另外,假設這是可能的,這是個好主意嗎?或者我會更好地習慣我的 html 將包含 4 次相同的鏈接的想法?)

(Also, assuming this is possible, is it a good idea? or would I be better just getting used to the idea that my html is going to contain the same links 4 times?)

實際上生成導航鏈接不是問題;我正在尋找清理輸出html

Actually generating the nav links is not an issue; I was looking to clean up the output html

推薦答案

有點可能,但仍不確定您是否愿意

并帶來一些嚴重的挑戰,具體取決于上下文.

一個問題是您的既定目標是減少 html 的混亂和冗余.但是,要獲得鏈接,您仍然需要有一個錨元素 (<a></a>) 作為鏈接的根.

One problem is that your stated goal is to reduce html clutter and redundancy. However, to have a link, you still need to have an anchor element (<a></a>) as the root for the link.

盡管如此,一種方法你可以用今天的瀏覽器做類似的事情(現在更普遍地支持偽元素)是將文本與 a 分開在您的代碼中留下一個 empty 錨.所以你仍然在代碼中有 HTML a,但消除了任何多余的 text.這真的有用嗎?不是我的想法.特別是如果您正在處理 內聯 鏈接,這些鏈接 是文本的一部分,因為您要做的就是通過偽元素將文本添加到這些鏈接中,喜歡:

Nevertheless, one way you could do something like that with today's browsers (now that pseudo-elements are more generally supported) is to divorce the text from the a which leaves an empty anchor in your code. So you still have the HTML a in the code, but eliminates any redundant text. How useful really is that? Not very is my thought. Especially if you are dealing at all with inline links that are part of the text, because what you would do is then add text to those links via the pseudo-element, something like:

a[href='#oneUrl']:before {
    content: 'your anchor text';
}

查看這個小提琴示例.

但是,還有另一種方法可以進一步減少 HTML,但有一些其他嚴重的限制.您可以在文本本身中有鏈接(比方說),這允許在其中包含相關的真實內容措辭.但是,它們中的每一個都可以有兩個(max)關聯的偽元素,可以擴展"為頁眉、頁腳等中的單獨鏈接.查看 這個小提琴示例.顯然,這要求您能夠精確定位這些鏈接(可能像示例中那樣使用 position:fixed),這可能具有挑戰性.然而,一個大問題是搜索引擎不會選擇那些額外的鏈接或它們的文本,屏幕閱讀器也不會,所以你的主導航"實際上在某種程度上變得不可見.這對我來說似乎是不可取的,但確實限制了你的 html 冗余.

However, there is another way that reduces HTML further, but has some other severe limitations. You could have links in the text itself (let's say), which allows for relevant real content wording in those. However, each of those can have two (max at present) pseudo-elements associated that could "extend" to be separate links in headers, footers, etc. Look at this fiddle example. Obviously, this requires you to be able to precisely locate those links (perhaps using position: fixed as the example has), which can be challenging. A big issue, however, is that search engines are not going to pick up those extra links or their text, and screen readers are not either, so your "main navigation" actually becomes invisible to some extent. That would seem to be undesirable to me, but it does indeed limit your html redundancy.

這篇關于使用 css 復制 html 元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix: quot;TypeError: Cannot read property #39;tag#39; of undefinedquot; error in discord.js(如何修復:“TypeError:無法讀取未定義的屬性‘標簽’discord.js 中的錯誤)
Discord.js Get common servers between two users(Discord.js 獲取兩個用戶之間的公共服務器)
How to fetch data which is not cached?(如何獲取未緩存的數據?)
Can#39;t reach members(無法聯系到成員)
SyntaxError: Unexpected token #39;?#39; when making discord bot in JavaScript on repl.it(SyntaxError:意外的令牌?在 repl.it 上用 JavaScript 制作不和諧機器人時)
Why does client.guilds.cache.size only say quot;0quot; in my playing status even if it#39;s in 2 servers?(為什么client.guilds.cache.size 只說“0?在我的游戲狀態中,即使它在 2 個服務器中?) - IT屋-程序員軟件開發技
主站蜘蛛池模板: 少妇精品久久久久久久久久 | 自拍偷拍亚洲视频 | 成人在线h | 色综合久久久久 | 成人精品啪啪欧美成 | 免费观看黄色一级片 | 日韩一区二区三区视频在线播放 | 精品蜜桃一区二区三区 | 天天摸天天干 | 国产一级片 | 日本三级在线网站 | 国产yw851.c免费观看网站 | 亚洲欧美一区二区三区1000 | 亚洲精品在线播放 | 亚洲高清视频在线观看 | 欧美精品一区二区免费 | 在线观看免费av网 | 国产精品波多野结衣 | 欧美影院 | 在线欧美a | 国产高清一二三区 | 亚洲一区二区三区免费在线观看 | 国产精品视频久久 | 在线免费观看毛片 | 久久久精品一区二区三区四季av | 久久成人一区 | 久久国产精品精品国产色婷婷 | 久久99精品久久久久久琪琪 | 亚洲成人精品 | 亚洲男女激情 | 国产精品久久久久久久久久久久冷 | 国产成人精品久久 | 成人在线一级片 | 日韩中文字幕网 | 精品视频一区二区 | 在线免费看毛片 | 日本a视频 | 国产精品视频偷伦精品视频 | 日本韩国电影免费观看 | 欧美久久久久久久久 | 亚洲国产情侣自拍 |