国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問(wèn)答1問(wèn)答10問(wèn)答100問(wèn)答1000問(wèn)答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題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關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問(wèn)答文章1 問(wèn)答文章501 問(wèn)答文章1001 問(wèn)答文章1501 問(wèn)答文章2001 問(wèn)答文章2501 問(wèn)答文章3001 問(wèn)答文章3501 問(wèn)答文章4001 問(wèn)答文章4501 問(wèn)答文章5001 問(wèn)答文章5501 問(wèn)答文章6001 問(wèn)答文章6501 問(wèn)答文章7001 問(wèn)答文章7501 問(wèn)答文章8001 問(wèn)答文章8501 問(wèn)答文章9001 問(wèn)答文章9501
當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

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

來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 16:09:08
文檔

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

求大神來(lái)看為li元素設(shè)置相同的padding為何padding-bottom和padding-right為多出一部分_html/css_WEB-ITnose:代碼如下 無(wú)標(biāo)題文檔 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
推薦度:
導(dǎo)讀求大神來(lái)看為li元素設(shè)置相同的padding為何padding-bottom和padding-right為多出一部分_html/css_WEB-ITnose:代碼如下 無(wú)標(biāo)題文檔 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

代碼如下
無(wú)標(biāo)題文檔


回復(fù)討論(解決方案)


哪里有問(wèn)題

看了半天沒(méi)看懂你問(wèn)的是什么


哪里有問(wèn)題


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

看了半天沒(méi)看懂你問(wèn)的是什么


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
就是說(shuō) offsetHeight 包含了 內(nèi)容, padding-top, padding-bottom, border-top, border-bottom, 以及涉及 scroollbar 的高度
box-sizing: content-box 指定元素的高度只包含內(nèi)容, 而不含其他.
你的代碼中, li 的高度之后被重設(shè), 并且總是比期望的要多出 padding-top + padding-bottom 的和.
而之后, padding-top 和 padding-bottom 并沒(méi)有變化, 都是你指定的 10px, 這多出的部分被加到了 content 的高度上, 但content 的字體并沒(méi)有變大, 而且文字又沒(méi)有被處理成在 content 中垂直居中, 所以看起來(lái)上下空白就不一樣了

所以可以加入以下 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.



這個(gè)定義表明 box-sizing 的默認(rèn)值是 content-box; box-sizing 的值將影響 css 中 height 的定義-- 垂直方向上的 padding 和 border 究竟會(huì)不會(huì)包含在 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.



這個(gè)定義表明 box-sizing 的默認(rèn)值是 content-box; box-sizing 的值將影響 css 中 height 的定義-- 垂直方向上的 padding 和 border 究竟會(huì)不會(huì)包含在 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.



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


但是如果 出現(xiàn)了滾動(dòng)條,頁(yè)面就會(huì)變成這個(gè)樣子

看了半天沒(méi)看懂你問(wèn)的是什么


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

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

但是如果 出現(xiàn)了滾動(dòng)條,頁(yè)面就會(huì)變成這個(gè)樣子



我分別在 Chrome 42, IE8, Firefox 39.0 測(cè)試, 只發(fā)現(xiàn) Firefox 存在這個(gè)問(wèn)題

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

這兒是為了實(shí)現(xiàn)一個(gè)滑動(dòng)效果,和padding沒(méi)關(guān)系吧,何況最終的高度并沒(méi)有改變


但是如果 出現(xiàn)了滾動(dòng)條,頁(yè)面就會(huì)變成這個(gè)樣子



我分別在 Chrome 42, IE8, Firefox 39.0 測(cè)試, 只發(fā)現(xiàn) Firefox 存在這個(gè)問(wèn)題


chrome43,IE11也存在問(wèn)題

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

這個(gè)函數(shù)來(lái)獲取li的高度就不會(huì)包括padding
謝謝,問(wèn)題解決了!

聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

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

求大神來(lái)看為li元素設(shè)置相同的padding為何padding-bottom和padding-right為多出一部分_html/css_WEB-ITnose:代碼如下 無(wú)標(biāo)題文檔 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
推薦度:
標(biāo)簽: 為什么 多一 li
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 国产精品第十页 | 欧美精品在线观看 | 自拍偷自拍亚洲精品被多人伦好爽 | 在线播放国产一区 | 国产在线精品一区二区 | 看全黄大色大黄美女 | 可以免费看的毛片 | 国内在线视频 | 亚洲精品综合久久中文字幕 | 激情欧美日韩一区二区 | 国产高清在线播放免费观看 | 夜夜骑日日操 | 国内精品久久久久影院不卡 | 亚洲欧洲高清有无 | 日韩欧美一区二区三区中文精品 | 五月婷婷丁香 | 久热中文字幕在线精品首页 | 综合视频在线 | 久久成人毛片 | 亚洲首页在线观看 | 欧美人与禽zoz0性伦交 | 精品久久久久久综合网 | 啪啪免费入口网站 | 亚洲色图欧美色 | 日本黄一级日本黄二级 | 在线观看视频一区 | 亚洲欧美日韩另类在线专区 | 欧美第一精品 | 国产精品第| 日产精品久久久一区二区 | 国产一区二区三区 韩国女主播 | 最新欧美日韩 | 日韩综合| 国外欧美一区另类中文字幕 | 能看毛片的网站 | 久久久性 | 国产成人精品一区二区视频 | 日韩精品123 | 日本精品一区二区三区在线观看 | 亚洲日韩在线视频 | 精品国产免费一区二区三区五区 |