100% width is bigger than parent's div

后端 未结 3 1180
感情败类
感情败类 2020-12-29 02:34

I\'m working on vBulletin theme, but on thread list, every thread has 100% for its width but threads are also bigger than their parents, but when i remove border of threads,

3条回答
  •  甜味超标
    2020-12-29 02:52

    The problem here is that the width is a size of the inner area with text, and the padding with border are "wrapped" around it. That specification makes no sense, but most modern browsers follow it.

    Your savior is called box-sizing: border-box;.

    .threadbit .thread {
    
        /* ... some stuff ... */
    
        -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
        -moz-box-sizing: border-box;    /* Firefox, other Gecko */
        box-sizing: border-box;         /* Opera/IE 8+ */
    }
    

    Look here: jsFiddle

    More info on this property here and here.

提交回复
热议问题