鱼C论坛

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

[已解决]一个span为何不能设置MARGIN-RIGHT

[复制链接]
发表于 2019-5-28 18:32:27 | 显示全部楼层    本楼为最佳答案   
本帖最后由 sukiwhip 于 2019-5-28 18:35 编辑
  1. <!DOCTYPE html>
  2. <html>

  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title></title>
  6.     <style type="text/css">
  7.         * {
  8.             margin: 0px;
  9.             padding: 0px;
  10.         }
  11.         
  12.         .page-left {
  13.             min-height: 1000px;
  14.             width: 60%;
  15.             height: 100%;
  16.             background-color: #22c3aa;
  17.             float: left;
  18.             transition: background-color 1s;
  19.         }
  20.         
  21.         .left-dis {
  22.             text-align: right;
  23.             margin-right: 10px;
  24.             margin-bottom: 20px;
  25.             color: white;
  26.             font-size: 50px;
  27.             font-weight: 500px;
  28.             transition: color 1s;
  29.         }
  30.         
  31.         .left-title {
  32.             margin-right: 20px;
  33.             height: 200px;
  34.             width: auto;
  35.             font-size: 20px;
  36.             display: block
  37.         }
  38.         
  39.         .ul-left {
  40.             list-style: none;
  41.             height: 100%;
  42.             width: 70%;
  43.         }
  44.         
  45.         .page-right {
  46.             min-height: 1000px;
  47.             width: 30%;
  48.             height: 100%;
  49.             background-color: white;
  50.             transition: background-color 1s;
  51.             float: left;
  52.         }
  53.         
  54.         .right-dis {
  55.             font-size: 50px;
  56.             margin-bottom: 20px;
  57.             font-weight: 500px;
  58.             margin-left: 5px;
  59.             color: #22c3aa;
  60.             transition: color 1s;
  61.         }
  62.         
  63.         .right-title {
  64.             display: inline-block;
  65.             font-size: 20px;
  66.         }
  67.         
  68.         .ul-right {
  69.             list-style: none;
  70.             height: 100%;
  71.             width: 30%;
  72.         }
  73.         
  74.         .page-left:hover {
  75.             background-color: white;
  76.         }
  77.         
  78.         .page-left:hover .left-dis {
  79.             color: #22c3aa;
  80.         }
  81.         
  82.         .page-left:hover+.page-right {
  83.             background-color: #22c3aa
  84.         }
  85.         
  86.         .page-left:hover+.page-right>.right-dis {
  87.             color: white
  88.         }
  89.     </style>
  90. </head>

  91. <body>
  92.     <div class="page-left">
  93.         <p class="left-dis">小树苗的</p>
  94.         <span class="left-dis left-title">
  95.                         <!--就是这里的span,设置了display和宽高,但是css中的margin-right为何会在父元素标签范围以外-->
  96.                                 <p>坦格利安家族的"风暴降生"</p>
  97.                                 <p>铁王座</p>
  98.                                 <p>安达尔人和先民的</p>
  99.                                 <p>七大王国守护者</p>
  100.                                 <p>大草海上的</p>
  101.                                 <p>不焚者镣铐</p>
  102.                         </span>
  103.         <ul class="ul-left">
  104.             <li>左</li>
  105.             <li>左</li>
  106.             <li>左</li>
  107.             <li>左</li>
  108.         </ul>
  109.     </div>
  110.     <div class="page-right">
  111.         <p class="right-dis">成长相册</p>
  112.         <span class="right-dis right-title">
  113.                                 <p>Daenerys</p>
  114.                                 <p>Lawful hei</p>
  115.                                 <p>Queen</p>
  116.                                 <p>Mother of Dragen</p>
  117.                                 <p>Khaleesi</p>
  118.                                 <p>Breaker</p>
  119.                         </span>
  120.         <ul class="ul-right">
  121.             <li>右边</li>
  122.             <li>右边</li>
  123.             <li>右边</li>
  124.             <li>右边</li>
  125.             <li>右边</li>
  126.         </ul>
  127.     </div>
  128. </body>

  129. </html>
复制代码

是想要这个效果?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-5-29 10:33:46 | 显示全部楼层
sxfxtf 发表于 2019-5-28 21:05
是的,多谢多谢,我看到哪里的问题了.我竟然忘记了auto这个值,蠢哭了

另外,如果你的浏览器宽度小于一定的范围,你的第一行会换行,导致左右不对称,当然,很少人会这样缩小浏览器。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-8 04:37

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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