Table of Contents
回复讨论(解决方案)
Home Web Front-end HTML Tutorial How to use css to make the background color of a div appear red in IE6, blue in IE7, and green in IE8? _html/css_WEB-ITnose

How to use css to make the background color of a div appear red in IE6, blue in IE7, and green in IE8? _html/css_WEB-ITnose

Jun 24, 2016 pm 12:01 PM
ie6 ie8 show green

在一个页面中编写css代码,实现下面的功能:

让一个div的背景色在IE6中显示成红色,在IE7中显示成蓝色,IE8中显示成绿色?


如何实现?请告知!分不够,可以加分!




回复讨论(解决方案)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style>.box{background:green\0;+background:blue;_background:red;width:200px;height:200px;}</style></head><body><div class="box"></div></body></html>
Copy after login

刚才没说完。同理ie7就是if IE 7,IE8就是if IE 8。IE和版本号之间有空格。然后在代码段里引入css样式表。样式表里就加个background-color:对应的颜色就可以了

刚才没说完。同理ie7就是if IE 7,IE8就是if IE 8。IE和版本号之间有空格。然后在代码段里引入css样式表。样式表里就加个background-color:对应的颜色就可以了



如何判断是ie6,ie7,ie8呢?


刚才没说完。同理ie7就是if IE 7,IE8就是if IE 8。IE和版本号之间有空格。然后在代码段里引入css样式表。样式表里就加个background-color:对应的颜色就可以了



如何判断是ie6,ie7,ie8呢?


<html>	<head>		<title></title>		<meta http-equiv="Content-sytle" content="text/html;charset=utf-8" />		<!-- 如果是ie6,那么加入ie6的样式表 -->		<!--[ if IE 6]>			<link rel="stylesheet" type="text/css" href="ie6.css" />		<![endif]-->		<!-- 同理ie7,ie8 -->		<!--[ if IE 7]>			<link rel="stylesheet" type="text/css" href="ie6.css" />		<![endif]-->		<!--[ if IE 8]>			<link rel="stylesheet" type="text/css" href="ie6.css" />		<![endif]-->		<!-- 另外if gt IE 8表示IE版本大于8.gte是小于等于.lt是小于 -->	</head>	<body>	</body></html>
Copy after login
Copy after login



刚才没说完。同理ie7就是if IE 7,IE8就是if IE 8。IE和版本号之间有空格。然后在代码段里引入css样式表。样式表里就加个background-color:对应的颜色就可以了



如何判断是ie6,ie7,ie8呢?


<html>	<head>		<title></title>		<meta http-equiv="Content-sytle" content="text/html;charset=utf-8" />		<!-- 如果是ie6,那么加入ie6的样式表 -->		<!--[ if IE 6]>			<link rel="stylesheet" type="text/css" href="ie6.css" />		<![endif]-->		<!-- 同理ie7,ie8 -->		<!--[ if IE 7]>			<link rel="stylesheet" type="text/css" href="ie6.css" />		<![endif]-->		<!--[ if IE 8]>			<link rel="stylesheet" type="text/css" href="ie6.css" />		<![endif]-->		<!-- 另外if gt IE 8表示IE版本大于8.gte是小于等于.lt是小于 -->	</head>	<body>	</body></html>
Copy after login
Copy after login



可以给出一个完整的例子吗?再加你分


demo.htm用来显示效果。

<!DOCTYPE html><html>	<head>		<title>demo</title>        <meta http-equiv="Content-sytle" content="text/html;charset=utf-8" />        <style type="text/css">        	div {         		color:white;        	}        </style>        <!--[if IE 6]>            <link rel="stylesheet" type="text/css" href="ie6.css" />        <![endif]-->        <!--[if IE 7]>            <link rel="stylesheet" type="text/css" href="ie7.css" />        <![endif]-->        <!--[if IE 8]>            <link rel="stylesheet" type="text/css" href="ie8.css" />        <![endif]-->	</head>	<body>		<div>			<p>this is a box.It will be red in ie6,blue in ie7,green in ie8.</p>		</div>	</body></html>
Copy after login

ie6.css:
div {	background-color: red;}
Copy after login

ie7.css
div {	background-color: blue;}
Copy after login

ie8.css
div {	background-color: green;}
Copy after login

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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

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)

How to remove news and trending content from Windows 11 Search How to remove news and trending content from Windows 11 Search Oct 16, 2023 pm 08:13 PM

When you click the search field in Windows 11, the search interface automatically expands. It displays a list of recent programs on the left and web content on the right. Microsoft displays news and trending content there. Today's check promotes Bing's new DALL-E3 image generation feature, the "Chat Dragons with Bing" offer, more information about dragons, top news from the Web section, game recommendations, and the Trending Search section. The entire list of items is independent of your activity on your computer. While some users may appreciate the ability to view news, all of this is abundantly available elsewhere. Others may directly or indirectly classify it as promotion or even advertising. Microsoft uses interfaces to promote its own content,

iOS 17's standby mode turns a charging iPhone into a home hub iOS 17's standby mode turns a charging iPhone into a home hub Jun 06, 2023 am 08:20 AM

In iOS 17 Apple is introducing Standby Mode, a new display experience designed for charging iPhones in a horizontal orientation. In this position, the iPhone is able to display a series of full-screen widgets, turning it into a useful home hub. Standby mode automatically activates on an iPhone running iOS 17 placed horizontally on the charger. You can view time, weather, calendar, music controls, photos, and more. You can swipe left or right through the available standby options and then long press or swipe up/down to customize. For example, you can choose from analog view, digital view, bubble font, and daylight view, where the background color changes based on time as time passes. There are some options

Windows 11 User Guide: How to disable ad pop-ups Windows 11 User Guide: How to disable ad pop-ups Sep 22, 2023 pm 07:21 PM

Microsoft's Windows 11 operating system may periodically display suggestions as pop-ups on your computer using the notification system. The suggestions system, originally intended to provide users with tips and suggestions for improving their Windows 11 workflows, has almost completely transformed into an advertising system to promote Microsoft services and products. Suggestion pop-ups might advertise a Microsoft 365 subscription to users, suggest linking an Android phone to the device, or set up a backup solution. If these pop-ups annoy you, you can tweak your system to disable them entirely. The following guide provides recommendations on disabling pop-ups on devices running Microsoft’s Windows 11 operating system.

Reasons and solutions for desktop layout being locked Reasons and solutions for desktop layout being locked Feb 19, 2024 pm 06:08 PM

What happens when the desktop layout is locked? When using the computer, sometimes we may encounter the situation where the desktop layout is locked. This problem means that we cannot freely adjust the position of desktop icons or change the desktop background. So, what exactly is going on when it says that the desktop layout is locked? 1. Understand the desktop layout and locking functions. First, we need to understand the two concepts of desktop layout and desktop locking. Desktop layout refers to the arrangement of various elements on the desktop, including shortcuts, folders, widgets, etc. we can be free

How to make a remote desktop connection display the other party's taskbar How to make a remote desktop connection display the other party's taskbar Jan 03, 2024 pm 12:49 PM

There are many users using Remote Desktop Connection. Many users will encounter some minor problems when using it, such as the other party's taskbar not being displayed. In fact, it is probably a problem with the other party's settings. Let's take a look at the solutions below. How to display the other party's taskbar during Remote Desktop Connection: 1. First, click "Settings". 2. Then open "Personalization". 3. Then select "Taskbar" on the left. 4. Turn off the Hide Taskbar option in the picture.

Samsung will provide displays for Microsoft's MR headsets, and the devices are expected to be lighter and have clearer displays Samsung will provide displays for Microsoft's MR headsets, and the devices are expected to be lighter and have clearer displays Aug 10, 2024 pm 09:45 PM

Recently, Samsung Display and Microsoft signed an important cooperation agreement. According to the agreement, Samsung Display will develop and supply hundreds of thousands of OLEDoS panels for mixed reality (MR) head-mounted devices to Microsoft. Microsoft is developing an MR device for multimedia content such as games and movies. This device is expected to It will be launched after the OLEDoS specifications are finalized, mainly serving the commercial field, and is expected to be delivered as early as 2026. OLEDoS (OLED on Silicon) technology OLEDoS is a new display technology that deposits OLED on a silicon substrate. Compared with traditional glass substrates, it is thinner and has higher pixels. OLEDoS display and ordinary display

How to display the wifi password QR code? It is recommended to scan the wifi password on WeChat in 3 seconds. How to display the wifi password QR code? It is recommended to scan the wifi password on WeChat in 3 seconds. Feb 20, 2024 pm 01:42 PM

You don’t need to enter the WIFI password often, so it’s normal to forget it. Today I will teach you the simplest way to find the password of your own WIFI. It can be done in 3 seconds. To check the WIFI password, use WeChat to scan it. The premise of this method is: there must be a mobile phone that can connect to WIFI. Okay, let’s start the tutorial: Step 1. We enter the phone, pull down from the top of the phone, bring up the status bar, and the WIFI icon. Step 2. Long press the WIFI icon to enter the WLAN settings; long press the WIFI icon. Step 3. Click Connected. Enter the WIFI name of your home, click Share Password, and a QR code will pop up; Step 4 of sharing WIFI password, we take a screenshot and save this QR code; Step 5, long press the WeChat icon on the desktop, and click Scan

How to turn on live captions instantly in Windows 11 How to turn on live captions instantly in Windows 11 Jun 27, 2023 am 08:33 AM

How to turn on live subtitles instantly in Windows 11 1. Press Ctrl+L on your keyboard 2. Click Agree 3. A popup will appear saying Ready to add subtitles in English (US) (depending on your preferred language) 4. Additionally, you can filter profanity by clicking the gear button? Preference? Filtering Swear Words Related Articles How to Fix Activation Error Code 0xc004f069 in Windows Server The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Pass these preliminary checks and if these checks do not

See all articles