Simply put : these two problems are actually the same problem, but I have been searching online for a long time but I can't find a method. There cannot be any HTML markup comments in the outlinked js and css files. Once there is, the browser will go crazy! Just remove it! ! !
Problem : The reason is that I saw a css table style online. I thought it looked pretty good, so I planned to put it in my Asp.Net program. At the beginning, I put it in the aspx file and it was displayed normally.
Then I planned to put css and js in a separate file. At this time, the browser went crazy. The display effect was completely different from the original inline. It was like I didn't see my css style sheet at all, but some styles were executed again, and some styles were ignored again. For example, the head of the table was executed well, but the border of the table was forced to be 2px; it was really unpleasant to be troubled by a small problem!
Solution : The solution is actually very simple. Remove all HTML tags <> and comments <!-- --> in the js and css files, and then it's OK!
Analysis : I checked the relevant information last night and mentioned that "when the browser does not find the relevant style sheet, it will use the css rendering parameters inside it to work."
The above picture is excerpted from Damo's book: "Illustrated CSS3: Core Technology and Case Practical Battle". This book is one of the few CSS3 books at present. Although I read the electronic version, I would consider buying one!
I saw that using the developer tools that come with the browser, it was true. When it could not be explained, I privately called the rendering parameters that come with the browser. The two paragraphs at the beginning of -webkit- in the figure below set the border of the table to 2px;
I looked at my JS file and removed this pair of HTML tags. It would be OK. The comment tags inside can be retained;
I looked at my css file again, which contained <!-- CSS goes in the document HEAD or added to your external stylesheet -->. I can't even have HTML comments in the css style file, otherwise there will be strange phenomenon that css is partially explained, and it will be fine once it is removed. It's so frustrating. It turns out that my mistake is caused by this small comment.
So how do you write comments in the css file? Just use the c annotation method /* comment*/
The above article briefly discusses the precautions for inline and external connection of JS and CSS is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.