I have a table in the center of my page
http://jsfiddle.net/YrBnd/3/
Is it possible to place the button in the example, just to the left of the table?
This highly skilled drawing should give you a better picture:
| |
| $$center |
| |
Where $$ is the button I want to place off center.
Absolutely positioned page elements will not affect the position of other elements and other elements will not affect them, whether they touch each other or not. There are four valid values for the float property. Left and Right float elements those directions respectively.
To center the text using float we can use margin-left or margin-right and make it 50% , like below.
You can do this by setting the display property to "flex." Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.
Try this approach, based on your jsfiddle:
HTML
<span>Center body text<button>Click</button></span>
CSS
span {
display: block;
width: 200px;
margin: 0 auto;
position: relative;
}
button {
position: absolute;
right: 100%;
}
http://jsfiddle.net/YrBnd/4/
The button is placed absolutely, from the right edge, to 100% of the width of the span element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With