RayT
asked on
Center control in div
Is there a way to center a web server control within a div using css3? If so, please provide an example.
Thanks
Thanks
A web server control is a bit high level for this discussion - a control will render out as html - how it renders to html will determine how you style it.
Centering is also 2 dimensional - vertical and horizontal. In HTML the latter is sometimes a lot easier to achieve than the former.
As Gary has mentioned is to give it a margin of auto - to center it - but this won't always work - you might have to look at giving the parent element a style of text-align: center. If you want to center vertically then that also needs discussion.
Can you give an example of the rendered html for the control in question.
Centering is also 2 dimensional - vertical and horizontal. In HTML the latter is sometimes a lot easier to achieve than the former.
As Gary has mentioned is to give it a margin of auto - to center it - but this won't always work - you might have to look at giving the parent element a style of text-align: center. If you want to center vertically then that also needs discussion.
Can you give an example of the rendered html for the control in question.
ASKER
I tried both suggestions. Neither worked. Here's my code.
<table>
<tr id="Billboard">
<td>
<div style="margin-left: 125px; padding-top: 5px;">
<dx:ASPxImageSlider ID="imgsBillboard" runat="server" ClientInstanceName="ImageSlider" EnableTheming="False" NavigateUrlFormatString="" Height="250px" Width="980px" SettingsSlideShow-PausePlayingWhenMouseOver="True" ViewStateMode="Enabled" ImageUrlField="ImageURL" NavigateUrlField="Billboard_NavigateURL" SettingsSlideShow-Interval="7000" Cursor="pointer">
<SettingsImageArea ImageSizeMode="ActualSizeOrFit" ItemTextVisibility="None" AnimationDuration="700" AnimationType="Fade" NavigationButtonVisibility="None" />
<SettingsBehavior ImageLoadMode="Auto" />
<SettingsNavigationBar Mode="Dots" />
<SettingsSlideShow AutoPlay="true" PlayPauseButtonVisibility="Faded"></SettingsSlideShow>
<SettingsAutoGeneratedImages ImageHeight="440px"></SettingsAutoGeneratedImages>
<ClientSideEvents ItemClick="function(s, e) {LaunchURL();}"></ClientSideEvents>
<Styles>
<NavigationBarDotsModeBottom>
<Margins MarginTop="4px" />
<Paddings PaddingTop="4px" />
</NavigationBarDotsModeBottom>
<ImageArea Width="980" Height="250">
</ImageArea>
<ItemTextArea Font-Names="Arial" Font-Size="11pt">
</ItemTextArea>
</Styles>
</dx:ASPxImageSlider>
</div>
</td>
</tr>
</table>
ASKER
Sorry for the sloppy code. Here's a cleaner version:
<div id="Billboard" style="margin-left: 125px; padding-top: 5px;">
<dx:ASPxImageSlider ID="imgsBillboard" runat="server" ClientInstanceName="ImageSlider" EnableTheming="False" NavigateUrlFormatString="" Height="250px" Width="980px" SettingsSlideShow-PausePlayingWhenMouseOver="True" ViewStateMode="Enabled" ImageUrlField="ImageURL" NavigateUrlField="Billboard_NavigateURL" SettingsSlideShow-Interval="7000" Cursor="pointer">
<SettingsImageArea ImageSizeMode="ActualSizeOrFit" ItemTextVisibility="None" AnimationDuration="700" AnimationType="Fade" NavigationButtonVisibility="None" />
<SettingsBehavior ImageLoadMode="Auto" />
<SettingsNavigationBar Mode="Dots" />
<SettingsSlideShow AutoPlay="true" PlayPauseButtonVisibility="Faded"></SettingsSlideShow>
<SettingsAutoGeneratedImages ImageHeight="440px"></SettingsAutoGeneratedImages>
<ClientSideEvents ItemClick="function(s, e) {LaunchURL();}"></ClientSideEvents>
<Styles>
<NavigationBarDotsModeBottom>
<Margins MarginTop="4px" />
<Paddings PaddingTop="4px" />
</NavigationBarDotsModeBottom>
<ImageArea Width="980" Height="250"></ImageArea>
<ItemTextArea Font-Names="Arial" Font-Size="11pt"></ItemTextArea>
</Styles>
</dx:ASPxImageSlider>
</div>
Are you wanting to center the image slider?
How is the control rendered on the client side? Do you have a link we can go to?
Have you tried something like this
HTML
However, without seeing how the control is rendered in the browser - just guessing.
How is the control rendered on the client side? Do you have a link we can go to?
Have you tried something like this
HTML
<dx:ASPxImageSlider .... CssClass="ASPxImageSlider" ....>
CSS.ASPxImageSlider {
margin: 0 auto;
}
However, without seeing how the control is rendered in the browser - just guessing.
Are we talking about the image slider?
margin auto will works since it has a set width
margin auto will works since it has a set width
ASKER
Here's the url to see what is going on.
http://www.newseasonministry.org/
I center the control with the following code:
<div id="Billboard" style="margin-left: 125px; padding-top: 5px;">
It's okay. I wanted to do something that's more reusable.
http://www.newseasonministry.org/
I center the control with the following code:
<div id="Billboard" style="margin-left: 125px; padding-top: 5px;">
It's okay. I wanted to do something that's more reusable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect! Thanks it works. The only change I had to make was the following:
#Billboard .dxisControl {
margin: 0 auto;
}
CSS/HTML is case sensitive.
#Billboard .dxisControl {
margin: 0 auto;
}
CSS/HTML is case sensitive.
You are welcome - thanks for the points.
So the first comment was wrong then...
ASKER
Yes. The selector was missing.
margin:auto;