i have a div with a asp.net label control
depending on the no of data in the control the div(label control)'s width increases . i want it to be of fixed size inspite of any amount of data.
i had head of clip property which clips the data to the width od the div.
how do i use it or is there any other way in which i can stop resizing of the div or the control
Set a specific width on the DIV, using CSS.
<div id="my-div">...</div>
#my-div {width:25em}
i had earlier tried with setting width property . if width set the div is set as per the width but the child element ie label control over here extends and the data is visible on it , so was thinking of clip or any other property wherein
though there are 10 elements ie element1,element2,…element 10
only few of them will be seen as per the width set at design time of both div and label control
other elemts will be clipped of
any way
stopping child element from exceeding parent element
here my parent element is div and child element is label control
how do i set the Clip property on div and obtain the result
It’s not clip
you want; that’s only applicable for absolutely positioned boxes. In this case you probably want overflow:hidden
(or auto
if you want scrollbars).
this is the css
#sdiv
{
/*clip:rect(top,right,bottom,left); */
background-color: #FFFFFF; left: 0; white-space: nowrap; text-overflow: ellipsis;
overflow:hidden;
clip:rect(0,100,0,0);
}
this is the html
<td class=“pad thback” style=“background-color: #c5c5c5; padding-right: 5px;”>
<div id='sdiv' >
<asp:Label ID="sdwndiv" runat="server" ForeColor="#808080" BackColor="White"
BorderColor="White" BorderStyle="Solid" BorderWidth="3px" Width="150px" Font-Size="XX-Small"></asp:Label>
<img alt="sImage" src="Images/dwn.gif" id="shape" onclick='showfilters(this);' /></div>
</td>
i tried using absolute positioning and it works position:absolute;
tahnks
but the problem is my full design changes . the div gets shifted . how do i adjust it
it is fine before appying position:absolute;
You have specified overflow:hidden
for #sdiv
, but you haven’t specified the dimensions for it. Since the initial value for the width
property is auto
, it will adjust to its content.
Specify the width you want plus overflow:hidden
. Forget about clip
.
hi alll
thanks
i have used overflow and set the width it works