<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        求大神來看為li元素設置相同的padding為何padding-bottom和padding-right為多出一部分_html/css

        來源:懂視網 責編:小采 時間:2020-11-27 16:09:08
        文檔

        求大神來看為li元素設置相同的padding為何padding-bottom和padding-right為多出一部分_html/css

        求大神來看為li元素設置相同的padding為何padding-bottom和padding-right為多出一部分_html/css_WEB-ITnose:代碼如下 無標題文檔 body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td,img {padding:0;margin:0;} #div1{ margin:10px; width:300px; height:2
        推薦度:
        導讀求大神來看為li元素設置相同的padding為何padding-bottom和padding-right為多出一部分_html/css_WEB-ITnose:代碼如下 無標題文檔 body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td,img {padding:0;margin:0;} #div1{ margin:10px; width:300px; height:2

        代碼如下
        無標題文檔


        回復討論(解決方案)


        哪里有問題

        看了半天沒看懂你問的是什么


        哪里有問題


        ul上下的padding是一樣的,但是下面的空白明顯大于上面

        看了半天沒看懂你問的是什么


        ul上下的padding一樣,但是下面的空白明顯大于上面

        這是 offsetHeight 的高度定義 和 li 的 box-sizing 是 content-box 相矛盾造成的

        The offsetHeight property returns the viewable height of an element in pixels, including padding, border and scrollbar
        就是說 offsetHeight 包含了 內容, padding-top, padding-bottom, border-top, border-bottom, 以及涉及 scroollbar 的高度
        box-sizing: content-box 指定元素的高度只包含內容, 而不含其他.
        你的代碼中, li 的高度之后被重設, 并且總是比期望的要多出 padding-top + padding-bottom 的和.
        而之后, padding-top 和 padding-bottom 并沒有變化, 都是你指定的 10px, 這多出的部分被加到了 content 的高度上, 但content 的字體并沒有變大, 而且文字又沒有被處理成在 content 中垂直居中, 所以看起來上下空白就不一樣了

        所以可以加入以下 CSS, 在 scroollbar 不存在的情況下, 就可以解決了

        li{ box-sizing: border-box;}

        W3C 上 box-sizing 的定義引用

        3.1. box-sizing property

        Name: box-sizing
        Value: content-box | border-box
        Initial: content-box

        content-box
        This is the behavior of width and height as specified by CSS2.1. The specified width and height (and respective min/max properties) apply to the width and height respectively of the content box of the element. The padding and border of the element are laid out and drawn outside the specified width and height.

        border-box
        Length and percentages values for width and height (and respective min/max properties) on this element determine the border box of the element. That is, any padding or border specified on the element is laid out and drawn inside this specified width and height. The content width and height are calculated by subtracting the border and padding widths of the respective sides from the specified width and height properties. As the content width and height cannot be negative ([CSS21], section 10.2), this computation is floored at 0. Used values, as exposed for instance through getComputedStyle(), also refer to the border box.



        這個定義表明 box-sizing 的默認值是 content-box; box-sizing 的值將影響 css 中 height 的定義-- 垂直方向上的 padding 和 border 究竟會不會包含在 height 中

        W3C 上 box-sizing 的定義引用

        3.1. box-sizing property

        Name: box-sizing
        Value: content-box | border-box
        Initial: content-box

        content-box
        This is the behavior of width and height as specified by CSS2.1. The specified width and height (and respective min/max properties) apply to the width and height respectively of the content box of the element. The padding and border of the element are laid out and drawn outside the specified width and height.

        border-box
        Length and percentages values for width and height (and respective min/max properties) on this element determine the border box of the element. That is, any padding or border specified on the element is laid out and drawn inside this specified width and height. The content width and height are calculated by subtracting the border and padding widths of the respective sides from the specified width and height properties. As the content width and height cannot be negative ([CSS21], section 10.2), this computation is floored at 0. Used values, as exposed for instance through getComputedStyle(), also refer to the border box.



        這個定義表明 box-sizing 的默認值是 content-box; box-sizing 的值將影響 css 中 height 的定義-- 垂直方向上的 padding 和 border 究竟會不會包含在 height 中



        W3C 上 box-sizing 的定義引用

        3.1. box-sizing property

        Name: box-sizing
        Value: content-box | border-box
        Initial: content-box

        content-box
        This is the behavior of width and height as specified by CSS2.1. The specified width and height (and respective min/max properties) apply to the width and height respectively of the content box of the element. The padding and border of the element are laid out and drawn outside the specified width and height.

        border-box
        Length and percentages values for width and height (and respective min/max properties) on this element determine the border box of the element. That is, any padding or border specified on the element is laid out and drawn inside this specified width and height. The content width and height are calculated by subtracting the border and padding widths of the respective sides from the specified width and height properties. As the content width and height cannot be negative ([CSS21], section 10.2), this computation is floored at 0. Used values, as exposed for instance through getComputedStyle(), also refer to the border box.



        這個定義表明 box-sizing 的默認值是 content-box; box-sizing 的值將影響 css 中 height 的定義-- 垂直方向上的 padding 和 border 究竟會不會包含在 height 中


        但是如果 出現了滾動條,頁面就會變成這個樣子

        看了半天沒看懂你問的是什么


        ul上下的padding一樣,但是下面的空白明顯大于上面

        你這里又給他加了高度
        //運動 var iheight=oli.offsetHeight; alert(iheight); oli.style.height="0"; move(oli,{height:iheight});

        但是如果 出現了滾動條,頁面就會變成這個樣子



        我分別在 Chrome 42, IE8, Firefox 39.0 測試, 只發現 Firefox 存在這個問題

        下面多余的部分不全是padding,還有一部分是li的高。
        oli.offsetHeight獲取的值是包括padding在內的,但是oli.style.height這樣賦值的高是不包括padding的。
        最簡單的解決方法就是減掉padding,即var iheight=oli.offsetHeight-20;
        但這樣解決效果不太好,因為oli.style.height=“0”;時其實padding部分還是看的見的。
        要效果好,也要簡單就用jquery吧,修改如下

        這兒是為了實現一個滑動效果,和padding沒關系吧,何況最終的高度并沒有改變


        但是如果 出現了滾動條,頁面就會變成這個樣子



        我分別在 Chrome 42, IE8, Firefox 39.0 測試, 只發現 Firefox 存在這個問題


        chrome43,IE11也存在問題

        下面多余的部分不全是padding,還有一部分是li的高。
        oli.offsetHeight獲取的值是包括padding在內的,但是oli.style.height這樣賦值的高是不包括padding的。
        最簡單的解決方法就是減掉padding,即var iheight=oli.offsetHeight-20;
        但這樣解決效果不太好,因為oli.style.height=“0”;時其實padding部分還是看的見的。
        要效果好,也要簡單就用jquery吧,修改如下

        這個函數來獲取li的高度就不會包括padding
        謝謝,問題解決了!

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        求大神來看為li元素設置相同的padding為何padding-bottom和padding-right為多出一部分_html/css

        求大神來看為li元素設置相同的padding為何padding-bottom和padding-right為多出一部分_html/css_WEB-ITnose:代碼如下 無標題文檔 body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td,img {padding:0;margin:0;} #div1{ margin:10px; width:300px; height:2
        推薦度:
        標簽: 為什么 多一 li
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 国产av无码专区亚洲av毛片搜| 色偷偷女男人的天堂亚洲网| 国产小视频在线免费| 亚洲免费视频网址| 亚洲免费一区二区| 曰批全过程免费视频播放网站| 亚洲AV区无码字幕中文色| 亚洲AV香蕉一区区二区三区| 国产精品免费观看久久| 亚洲乱码国产乱码精品精| 91在线亚洲综合在线| 免费无码黄网站在线看| 久久久久久亚洲av成人无码国产| 久久免费视频精品| 亚洲国产综合无码一区二区二三区| 亚洲黄色中文字幕| 九九精品免费视频| 亚洲精品线在线观看| 免费A级毛片无码视频| 亚洲AV无码一区二区三区在线| 色窝窝免费一区二区三区| 亚洲精品无码mⅴ在线观看| www.亚洲一区| 亚洲欧美一区二区三区日产| 免费大黄网站在线观| 亚洲国产系列一区二区三区 | 亚洲变态另类一区二区三区| 免费A级毛片无码久久版| a在线视频免费观看在线视频三区| 亚洲第一AAAAA片| 青青青国产在线观看免费网站| 亚洲av无码一区二区三区在线播放 | 亚洲精品无码Av人在线观看国产 | 亚洲国产成人影院播放| 在线涩涩免费观看国产精品| 亚洲剧情在线观看| 亚洲精品一级无码中文字幕| 在线观看的免费网站无遮挡| 国产精品亚洲AV三区| 久久精品亚洲一区二区| 免费看大美女大黄大色|