Change Position Of Html Element?
Solution 1:
top
only works with certain position
values. Use a margin instead, like so:
<h2 id="loginText" style="margin-top:383px" >Login</h2>
This should work for what you need. You can also move it to the right using margin-left
, etc.
If you want to use top
, you can do something like this:
<h2 id="loginText" style="position: absolute; top:383px" >Login</h2>
Absolute positioning lets you use top
, left
, right
, and bottom
to absolutely position elements on the page
You can read up more on the position
property here and the top
property here
Solution 2:
Without the CSS it's hard to tell what the problem is, but my guess would be that you haven't declared a position attribute to the element, which means it defaults to position: static
, meaning it won't move. So if you want to move the item you would need to declare position: relative
and then apply the top: 383px
. That being said, it is more common to just set margin-top: 383px
. Again, if you add a copy of the CSS you're using it will be easier to address the issue.
Solution 3:
best positioning of your login form is to populate form in <div>
. Than you can set to this div center (horizontaly) of screen by use style margin: 0 auto;
and to vertical align, you can use some js or margin-top:
, but use a % ... (dont forget to smaller screens than you have)
Solution 4:
make sure you define the position type.
<h2 id="loginText" style="top:383px; position:fixed" >Login</h2>
fixed means that the position (top:383px) is relative to the window. there are also other position types such as absolute, relative, or sticky.
Solution 5:
dude use <div class="container m-5">
it will give your some margin from top and will create a container for you
Post a Comment for "Change Position Of Html Element?"