Post Views: 6
The following CSS code will align the absolute positioned div inside a container.
Note: This will only work depending on the max-width of the container. Need to adjust for mobile devices.
<!Doctype html>
<html>
<head>
<style>
.page-body {
max-width: 800px;
background: #ccc;
position: relative;
display: flex;
flex-direction: column;
align-items: center;
padding: 100px;
}
.page-container {
max-width: 500px;
background: #eee;
display: block;
padding: 20px;
}
.abs-position {
position: absolute;
top: 50px;
right: calc((100% - 500px)/2 + 0px);
padding: 20px;
text-align: center;
border: 1px solid #ccc;
border-radius: 10px;
background: #a5f6c0;
width: 200px;
}
</style>
</head>
<body>
<div class="page-body">
<div class="page-container">
<h1>Page title</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div class="abs-position">I am positioned absolute!</div>
</div>
</body>
</html>
Page title
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
I am positioned absolute!
How to Use WebP Images in WordPress?
/in WordPressWebp images are not allowed to WordPress media library with default setting. To enable the .webp format use the following code block in your functions.php file inside the theme folder.
How to style second last items in a list?
/in CSS, htmlPlease use following CSS syntax to style the second last element in a list or group.
How to extend number of DIVI columns (more than 6)?
/in CSS, DIVI, htmlStep 01: Include the below CSS to theme options
Step 02: Add the relevant class to your row, depending on the number of columns needed.
Step 03: Remember to only keep one column in the DIVI row settings and use DIVI modules as columns. That’s it Happy Coding!
How to center a div vertically and horizontally using CSS?
/in CSS, DIVI, htmlPlease use following method to align any content vertically and horizontally centered..
How align an absolute positioned div relative to the max-width of contents?
/in htmlThe following CSS code will align the absolute positioned div inside a container.
Note: This will only work depending on the max-width of the container. Need to adjust for mobile devices.
Page title
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
How to convert any full URL path to relative to WordPress installation (root)
/in WordPressIf you want to make a URL relative from the WordPress root, you can use the following WordPress function.
Result: /how-to-programmatically-add-a-wordpress-admin-user-using-functions-php/
That’s all! Happy coding!