开发者

Wrapping span tags inside a div

开发者 https://www.devze.com 2023-01-17 10:15 出处:网络
I have a couple of div tags nested within each other and a few span tags nested like below:- <div id=\"leftcol\">

I have a couple of div tags nested within each other and a few span tags nested like below:-

<div id="leftcol">
    <div id="tagcloud">
        <span class="mytags"><a href="">tag1</a></span>
        <span class="mytags"><a href="">tag2</a></span>
        <!-- and a few more spans of the same type -->
    </div>
</div>

Now the issue is that spans overflow their container div tag. Can somebody be kind enough to let me know how to get these spans to be wrapped inside their container div (here the div with the id tagcloud). Both the outer divs have a width of 300px specified.

(Additional info- I have done a CSS reset using the YUI reset-fonts开发者_JS百科-grids. I am just getting accustomed with CSS.) -The site can be looked at frekshrek.appspot.com... the tag cloud just does not wrap inside its container div


Other option is to just set your tags to be displayed inline-block:

.mytags {
   display:inline-block;
}


Try declaring float: left; on the .mytagcloud class. Something like:

.mytagcloud{
    float: left;
    margin: 5px;
    font-family: 'Reenie Beanie', arial, serif;
}

in your basiclayout.css file, line 71.


You have no spaces between your spans, so the browser sees them all as one single long word. If you add a single space or a line break between each span they will be treated as separate words and wrapped accordingly.


It sounds like you are floating the spans inside the div container. If this is the case, and you want the 'tagcloud' to contain (wrap) the floated spans then you need to clear the floats by adding the following to the tagcloud CSS:

div.tagcloud {
    overflow: auto;
    width: 100%;
}

An explanation of this technique can can be found here: http://www.quirksmode.org/css/clearing.html

0

精彩评论

暂无评论...
验证码 换一张
取 消