CSS: series of floated elements without wrapping but rather scrolling horizontally

后端 未结 10 1627
无人及你
无人及你 2021-02-01 04:25

I\'m working on a album viewer. At the top I want a horizontal container of all the image thumbnails. Right now all the thumbnails are wrapped in a div with float:left

10条回答
  •  难免孤独
    2021-02-01 04:53

    It is a common mistake thinking that setting the white-space property to "nowrap" also works on floated elements. It only works on inline elements or inline-block elements.

    I guess you need the floated elements to be a block, so you could turn them into inline blocks. It is possible to gain it on all the browsers with some trick:

    display: -moz-inline-stack;
    display: inline-block;
    zoom: 1;
    *display: inline;
    

    This solution opens a lot of new web-design sceneries to be explored, so I gratefully give the proper credits to the author: http://foohack.com/2007/11/cross-browser-support-for-inline-block-styling/

    Here you can read a document which speaks of the white-space property and the floated elements: http://reference.sitepoint.com/css/white-space

    Cheers!

提交回复
热议问题