Solved

How do you center a silverlight object within an HTML page?

Posted on 2008-06-25
2
1,716 Views
Last Modified: 2013-11-12
I'm trying to center a silverlight app that I've created within an html page.  I believe this is a simple thing to do with CSS, however when I tried a few of the things I saw on the Internet they didn't seem to work.  Below is a snippet of the style section and the object tag from my site.   You can view the actual site at www. silverlightwebapps.com

    <style type="text/css">
    html, body {
          height: 1000px;
          overflow: scroll;
    }
    body {
          padding: 0;
          margin: 0;
    }
    #silverlightControlHost {
          height: 1000px;
          width:800px;
          overflow:scroll;
          
    }
    </style>
   
... later, within the body tag...
    <div id="silverlightControlHost">
            <object data="data:application/x-silverlight," type="application/x-silverlight-2-
0
Comment
Question by:mdobbles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
codeQuantum earned 500 total points
ID: 21871651
In your HTML put a DIV inside your <body> and give an ID="wrapper"

<body>
<div id="wrapper">
... your html here
</div>
</body>

Then change the CSS as following :
    html, body {
          height: 1000px;
          overflow: scroll;
text-align: center;
    }
 
#wrapper {
margin: 0 auto;
text-align: left;
width:800px;
}

Open in new window

0
 
LVL 8

Expert Comment

by:adler77
ID: 21889606
To center horizontally, you can use "text-align: center;" as noted above. To center vertically, set the css for your Silverlight div to "top: 50%; margin-top: -412px;" (I'm assuming your app is 800x825, as in the other thread. Whatever it is, set the margin-top to NEGATIVE 1/2 of the height).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question