Issue
I want to align a div to the right side of an other div using margin-left: auto;
but for some reason this does nothing. If the div is not contained by another div, this approach works flawlessly.
This is an example of the problem:
<!DOCTYPE html>
<html>
<body>
<style>
#inner {
margin-left: auto;
}
</style>
<div id="outer">
<div id="inner">
Text
</div>
</div>
</body>
</html>
Solution
You can add a width to the inner div (#inner
) and the margin will take up the remaining space.
#inner {
margin-left: auto;
width: 50%;
border: 1px solid red;
}
<div id="outer">
<div id="inner">
Text
</div>
</div>
Answered By - haldo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.