鱼C论坛

 找回密码
 立即注册
查看: 3042|回复: 5

[已解决]为何用了CSS导入模式会使得页面出现问题

[复制链接]
发表于 2019-2-10 06:47:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 sxfxtf 于 2019-2-10 06:48 编辑

新鱼友,权限不够无法上传图片.
自己写了个百度网页,把CSS代码写在<head>标签中显示都OK,
但是我把CSS单独写到一个文件后用<link> (79行)导入后字体就不不会居中显示了,请问这个是什么问题?


  1. <!DOCTYPE html>
  2. <html>
  3.         <head>
  4.                 <meta charset="utf-8">
  5.                 <title></title>
  6.                 <style type="text/css">
  7.                
  8.                 body{
  9.                         text-align: center;
  10.                 }
  11.                 .over_head{
  12.                         height:8px;
  13.                 }
  14.                 .head{
  15.                         height: 150px;
  16.                         text-indent: 1420px;
  17.                         word-spacing: 10px;
  18.                         /* background-color: pink; */
  19.                 }
  20.                 .more_product{
  21.                         color: white;
  22.                         background-color: #38f;
  23.                         padding: 5px;
  24.                 }
  25.                 .head a{
  26.                         font-size: 14px;
  27.                 }
  28.                 .guid{
  29.                         color: black;
  30.                         font-weight: bold;
  31.                 }
  32.                 .guid-1{
  33.                         color: black;
  34.                 }
  35.                 input[type=text]{
  36.                         width: 500px;
  37.                         height: 30px;
  38.                 }
  39.                 input[type=button]{
  40.                         height: 38px;
  41.                         width: 100px;
  42.                         background-color: #38f;
  43.                         color: white;
  44.                         border: 0px;
  45.                         font-size: 15px;
  46.                 }
  47.                 .body{
  48.                         height: 580px;
  49.                         /* background-color: orange; */
  50.                 }
  51.                 .footer p {
  52.                         font-size: 12px;
  53.                         color: #666;
  54.                 }
  55.                 .underfloor1{
  56.                         word-spacing: 12px;
  57.                         font-size: 10px;
  58.                         height: 20px;
  59.                 }
  60.                 .underfloor1 a{
  61.                         color: #999;
  62.                 }
  63.                 .underfloor2{
  64.                        
  65.                         color: #999;
  66.                         word-spacing: 5px;
  67.                         font-size: 10px;
  68.                         height: 20px;
  69. /*                         background-color: aquamarine;
  70.                         background-image: url(icon.gif);
  71.                         background-position: -1000px -96px;
  72.                          */
  73.                 }
  74.                 .underfloor2 a{
  75.                         color: #999;
  76.                        
  77.                 }
  78.                 </style>
  79.                 <!-- <link rel="stylesheet"  href="new_file.css"/> -->

  80.         </head>
  81.         <body>
  82.                 <div class="over_head">
  83.                        
  84.                 </div>
  85.                 <div class="head">
  86.                         <a href="#" class="guid">新闻</a>
  87.                         <a href="#" class="guid">hao123</a>
  88.                         <a href="#" class="guid">地图</a>
  89.                         <a href="#" class="guid">视频</a>
  90.                         <a href="#" class="guid">贴吧</a>
  91.                         <a href="#" class="guid">学术</a>
  92.                         <a href="#" class="guid-1">登陆</a>
  93.                         <a href="#" class="guid-1">设置</a>
  94.                         <a href="#" class="more_product">更多产品</a>
  95.                        
  96.                 </div>
  97.                 <div class="body">
  98.                         <img src="bd_logo1.png" width="270"px height="129"px>
  99.                 <div id="" class="search">
  100.                         <input type="text" name="" id="" value="" />
  101.                         <input type="button" name="" id="" value="百度一下" />
  102.                 </div>       
  103.                 </div>
  104.                 <div class="footer">
  105.                         <div id="">
  106.                         <img src="ewm.png" width="65px">
  107.                         <p>百度</p>
  108.                         </div>
  109.                         <div class="underfloor1" >
  110.                         <a href="#">把百度设为主页</a>
  111.                         <a href="#">关于百度</a>
  112.                         <a href="#">About  Baidu</a>
  113.                         <a href="#">百度推广</a>
  114.                         </div>
  115.                         <div  class = "underfloor2">
  116.                        
  117.                         &#169;2019&nbsp;Baidu&nbsp;
  118.                         <a href="#">使用百度前必读 意见反馈</a>
  119.                         京ICP证030173号
  120.                         <a href="#">京公网安备11000002000001号 </a>
  121.                        
  122.                         </div>
  123.                

  124.         </body>
  125. </html>
复制代码
最佳答案
2019-2-10 09:14:33
1、样式冲突,按照优先级排序设置“唯一”的css,建议将代码发全

2、可以将封装后的xxx.css,通过 link 嵌入并放置 head 元素中
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-2-10 09:09:46 | 显示全部楼层
你得给我们看看new_file.css里得代码,我目测是new_file.css中的代码与你上面的css样式层叠了。你试试把new_file.css代码放在前面。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-2-10 09:14:33 | 显示全部楼层    本楼为最佳答案   
1、样式冲突,按照优先级排序设置“唯一”的css,建议将代码发全

2、可以将封装后的xxx.css,通过 link 嵌入并放置 head 元素中
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-2-10 20:41:04 | 显示全部楼层
像番茄加两个蛋 发表于 2019-2-10 09:09
你得给我们看看new_file.css里得代码,我目测是new_file.css中的代码与你上面的css样式层叠了。你试试把new ...

CSS代码就是从我发的这个代码中复制过去的.都一样
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-2-10 20:42:06 | 显示全部楼层
不二如是 发表于 2019-2-10 09:14
1、样式冲突,按照优先级排序设置“唯一”的css,建议将代码发全

2、可以将封装后的xxx.css,通过 link  ...

我级别不够,没办法发附件上来.所以只能把代码上传了.我自己在研究下你说的 原因1,多谢
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-2-11 07:36:33 | 显示全部楼层
sxfxtf 发表于 2019-2-10 20:42
我级别不够,没办法发附件上来.所以只能把代码上传了.我自己在研究下你说的 原因1,多谢

试着在xxx.css文件中调整z-index层级关系哈
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-8 18:47

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表