從下面的代碼中,我剪切并粘貼了& ltstyle & gt節替換為& ltlink rel = & quot樣式表& quothref = & quotstyles.css & quot& gt,但呈現方式不同。請告訴我如何保護原始樣式,即使我把它們移動到一個. css文件中。
-& gt;現在我看到它工作正常。抱歉讓大家困惑了。
聲明:這段代碼是由ChatGPT生成的。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Data Provider Site</title>
<style>
/* Add your custom styles here */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #ffffff;
color: #e2b931;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
}
nav {
background-color: #c8beb8;
padding: 10px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
nav ul li {
display: inline-block;
}
nav ul li a {
display: block;
padding: 10px;
text-decoration: none;
color: #333;
}
nav ul li a:hover {
background-color: #ddd;
}
main {
padding: 20px;
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
</style>
</head>
<body>
<header>
<h1>Data Provider Site</h1>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Pricing</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<main>
<!-- Add your content here -->
<h2>Welcome to Our Data Provider Site</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et iaculis arcu. Duis sed nulla eu enim ullamcorper ultricies.</p>
</main>
<footer>
<p>© 2023 Your Company. All rights reserved.</p>
</footer>
</body>
</html>
原始頁面
用單獨的頁面。css文件
樣式. css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #1e155e;
color: #fff;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
}
nav {
background-color: #f4f4f4;
padding: 10px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
nav ul li {
display: inline-block;
}
nav ul li a {
display: block;
padding: 10px;
text-decoration: none;
color: #333;
}
nav ul li a:hover {
background-color: #ddd;
}
main {
padding: 20px;
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temp</title>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body>
<header>
<h1>Temp</h1>
</header>
<nav>
<ul>
<li><a href="data.html">Data</a></li>
<li><a href="lesson.html">Lesson</a></li>
<li><a href="about.html">About</a></li>
</ul>
</nav>
<main>
<!-- Add your content here -->
<h2>Welcome to Our Data Provider Site</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et iaculis arcu. Duis sed nulla eu enim ullamcorper ultricies.</p>
</main>
<footer>
<p>© 2023 . All rights reserved.</p>
</footer>
</body>
</html>
你的代碼對我來說很好。在這里,我附上了我的工作代碼和從代碼生成的截圖。
您可以嘗試清除瀏覽器緩存。有時瀏覽器緩存也是個問題。
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #1e155e;
color: #fff;
padding: 20px;
text-align: center;
}
h1 {
margin: 0;
}
nav {
background-color: #f4f4f4;
padding: 10px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
nav ul li {
display: inline-block;
}
nav ul li a {
display: block;
padding: 10px;
text-decoration: none;
color: #333;
}
nav ul li a:hover {
background-color: #ddd;
}
main {
padding: 20px;
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temp</title>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body>
<header>
<h1>Temp</h1>
</header>
<nav>
<ul>
<li><a href="data.html">Data</a></li>
<li><a href="lesson.html">Lesson</a></li>
<li><a href="about.html">About</a></li>
</ul>
</nav>
<main>
<!-- Add your content here -->
<h2>Welcome to Our Data Provider Site</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et iaculis arcu. Duis sed nulla eu enim ullamcorper ultricies.</p>
</main>
<footer>
<p>© 2023 . All rights reserved.</p>
</footer>
</body>
上一篇python 畫繪圖模塊
下一篇mui與vue關系