Table of Contents
Reply to discussion (solution)
Home Web Front-end HTML Tutorial How to modify the CSS reference of the html frontend?_html/css_WEB-ITnose

How to modify the CSS reference of the html frontend?_html/css_WEB-ITnose

Jun 24, 2016 am 11:58 AM
css html Revise Quote

The head part of the original html frontend references a style.css style

1

<LINK href="Css/style.css" type="text/css" rel="stylesheet">

Copy after login




Now I want to use the style7.css style to overwrite the style. css style

First, add the style7.css style to the Head section of the html frontend. You can use the following method to achieve it

1

HtmlLink link = new HtmlLink();link.Attributes.Add("type", "text/css");link.Attributes.Add("rel", "stylesheet");link.Attributes.Add("href", "style7.css");this.Header.Controls.Add(link);

Copy after login



But now html The head part of the front desk references two styles



1

&lt;LINK href=&quot;Css/style.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;&gt;<LINK href="Css/style7.css" type="text/css" rel="stylesheet">

Copy after login




The question now is: how to reference the style.css Remove it from the head of the html frontend?




Reply to discussion (solution)

1

<!doctype html><html><head>    <meta charset="UTF-8">    <title></title>    &lt;LINK href=&quot;Css/style.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot;&gt;    <LINK href="Css/style7.css" type="text/css" rel="stylesheet"></head><body><script type="text/javascript">    var link = document.getElementsByTagName('link');    for(var i = 0; i<link.length; i++){        if(link[0].href.indexOf('style.css') > -1){            link[0].parentNode.removeChild(link[0]);        }    }</script></body></html>

Copy after login

The middle one 0 is i.

1

var link = document.getElementsByTagName('link');for(var i = 0; i&lt;link.length; i++){    if(link[i].href.indexOf('style.css') &gt; -1){        link[i].parentNode.removeChild(link[i]);    }}

Copy after login

Your business logic
Add a
and go to a


Then the synthesis is to modify a
and borrow the code above
var link = document.getElementsByTagName('link');
for(var i = 0; i<link.length; i ){
if(link[i].href.indexOf('style.css ') > -1){
        link[i].href = 'style7.css';

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

Nested Table in HTML

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Table Border in HTML

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

HTML margin-left

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

HTML Table Layout

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Moving Text in HTML

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

HTML Ordered List

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

How do you parse and process HTML/XML in PHP?

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

HTML onclick Button

See all articles