Why do my list item bullets overlap floating elements

前端 未结 23 1291
半阙折子戏
半阙折子戏 2020-11-28 18:00

I have an (XHTML Strict) page where I float an image alongside regular paragraphs of text. All goes well, except when a list is used instead of paragraphs. The bullets of th

23条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 18:20

    After fighting with this interesting issue in several projects, and investigating why it happens, I finally believe I found both: a working and 'responsive' solution.

    Here is the magic trick, live example: http://jsfiddle.net/superKalo/phabbtnx/

    ul {
        list-style: none;
        position: relative;
        padding-left: 0; /* remove any left padding */
        margin-left: 0; /* remove any left margin */
        left: 35px;
    }
    li {
        padding-left: 0; /* remove any left padding */
        margin-left: 0; /* remove any left margin */
        text-indent: -19px; /* adjust as much as needed */
    }
    li:before {
        content: '•\00a0\00a0\00a0';
        color: #000; /* bonus: you can customize the bullet color */
    }
    

提交回复
热议问题