Automatically resize and vertically align a centrally positioned div in a designated container

I have a div container that is centered in the middle of another container. I managed to adjust it for one slide, but the issue arises when I create multiple .html files using the same css file - the height of the container does not meet my expectations. Ideally, I want the height of the container to automatically adjust based on the content within it, while still accounting for margins, padding, and other styling attributes applied to the content container.

Below you will find my code snippets as well as an image showcasing the current output:

.template-benefits{
width: 100%;
padding-bottom: 50px;
position: relative;
}
.tbenefitswrpr {
width: 1000px;
margin: auto;
height: 400px;
padding: 50px 0 0 0 ;
}
.template-benefits h3{
font-weight: normal;
font-size: 1.3em;
color: rgb(150,150,150);
}
.template-benefits ul li{
list-style-type: disc;
}

.tbenefitswrpr h1{
font-weight: bold;
margin: 0px;
padding: 0px;
margin-bottom: 30px;
}
.tbenefitswrpr ul{
padding: 0px 0px 0px 20px;
}
.tbenefitswrpr li{
padding-bottom: 20px;
font-size: 1.2em;
font-weight: bold;
}
<div class="template-benefits">
<div class="tbenefitswrpr">
<div class="tbenefits-left">
<h1>Preventative maintenance of equipment and assets</h1>
<ul>
<li>Schedule recurring work orders for routine preventative maintenance for anything from computers, technology, and other appliances or equipment</li>
<li>Easily view schedule of past completed maintenance work orders</li>
<li>Custom dashboards to track preventative maintenance</li>
</ul>
</div>
<div class="tbenefits-right">
<h1>Building and facility management</h1>
<ul>
<li>Manage multiple facilities all in one organized place</li>
<li>Easily view past completed security and safety inspections</li>
<li>Assign and coordinate work orders for repairs for utilities, plumbing, and broken appliances</li>
</ul>
</div>
</div>
</div>

Desired Output

Answer №1

Here's a helpful CSS class you can use:

.tbenefits-left{float: left;width: 50%;margin-right: 20px;}

Answer №2

Is this the desired format?

.template-benefits{
width: 100%;
padding-bottom: 50px;
position: relative;
}
.tbenefitswrpr {
width: 1000px;
margin: auto;
height: 400px;
padding: 50px 0 0 0 ;
}
.template-benefits h3{
font-weight: normal;
font-size: 1.3em;
color: rgb(150,150,150);
}
.template-benefits ul li{
list-style-type: disc;
}

.tbenefitswrpr h1{
font-weight: bold;
margin: 0px;
padding: 0px;
margin-bottom: 30px;
}
.tbenefitswrpr ul{
padding: 0px 0px 0px 20px;
}
.tbenefitswrpr li{
padding-bottom: 20px;
font-size: 1.2em;
font-weight: bold;
}

/*---update---*/
.tbenefits-left{
    float: left;
    width: 50%;
    margin-right: 20px;
 }
<div class="template-benefits">
<div class="tbenefitswrpr">
<div class="tbenefits-left">
<h1>Preventative maintenance of equipment and assets</h1>
<ul>
<li>Schedule recurring work orders for routine preventative maintenance for anything from computers, technology, and other appliances or equipment</li>
<li>Easily view schedule of past completed maintenance work orders</li>
<li>Custom dashboards to track preventative maintenance</li>
</ul>
</div>
<div class="tbenefits-right">
<h1>Building and facility management</h1>
<ul>
<li>Manage multiple facilities all in one organized place</li>
<li>Easily view past completed security and safety inspections</li>
<li>Assign and coordinate work orders for repairs for utilities, plumbing, and broken appliances</li>
</ul>
</div>
</div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Firebug displays CSS rule as blank

When I look at the styles in Firebug, I notice that the rule below has no content: .holest-carousel-top-item { box-shadow: 1px 1px 1px #FFF,-1px -1px 1px #9ACC67;border-radius: 85px; } Additionally, this rule is not displaying correctly in Firefox. ...

Creating unique styles with styled components without the use of selectors

Is it possible to achieve contextual styling without using CSS selectors? For example: <Button primary> <Text>BUTTON</Text> // if the button is primary then have 20px padding else 0 <Icon/> // if the button is primary then ...

Invoke a JavaScript function once the div has finished loading

After clicking on a radio button, I am dynamically loading a div element. I want to hide a specific part of the div once it is loaded. $(function($) { $('.div_element').on('load', function() { $('.textbox').hide(); } ...

Having difficulty positioning breadcrumb items to float on the right side

As I create my Vue.js and Bootstrap application, I am working on a breadcrumb feature that presents some challenges. Specifically, I am trying to align the icons to the right while ensuring that the text "Files" remains floated to the left. <script s ...

Adjust the column count in mat-grid-list upon the initial loading of the component

My goal is to implement a mat-grid-list of images with a dynamic number of columns based on the screen size. Everything works perfectly except for one small glitch – when the grid first loads, it defaults to 3 columns regardless of the screen size until ...

What is the best way to create a grid layout that is responsive using HTML and CSS

I have been searching all over the internet and have not been able to find a grid layout like this. The "grid-template-columns" property is not achieving what I need, as I cannot make one box larger than the others. I am looking to create 4 equal boxes an ...

What is the best way to create a toggle effect for a <nav> bar that appears from beneath a div?

I need assistance with a navigation setup where the nav (located inside the header) needs to be connected to the bottom of a div named .menu_bar. The desired behavior is for the nav to slide down from directly underneath the .menu_bar when toggled, but cur ...

What is the process for printing the CSS stylesheet for PPI::HTML highlight?

PPI::HTML has done an impressive job of formatting the HTML highlighting for my Perl code, similar to the example on CPAN. However, I am facing challenges in making the output usable without the appropriate CSS styles. Unfortunately, I am unsure of how to ...

Display the footer once the user has reached the end of the page by scrolling

Below is the footer code I am working with. <div class="row"> <div class="col-md-12"> <div> this section always remains at the bottom </div> </div> <div class="col-md-12"> <div> only v ...

ColdFusion encounters an HTML form error, presenting the message: "There is an undefined element in the FORM."

I'm attempting to submit an HTML form that contains checkboxes for each day of the week. Whenever a checkbox is checked, I assign a value of 1 to it. To handle unchecked checkboxes, I set a default value of 0 using a CFPARAM tag in the form action pag ...

Can pagination numbers in Jquery DataTable be configured based on the total records returned by the server and the number of records chosen by the user?

I am currently diving into the world of DataTable.js, a jQuery plugin, and working hard to articulate my questions effectively. For my specific needs, I need to retrieve only 10 records initially whenever an AJAX request is made, even if there are 100 rec ...

The sign out option fails to erase the data stored in Local Storage

After implementing a login feature that stores a token in local storage, I encountered an issue with the logout button. The intention was for the button to delete the token from local storage and set the user to null upon clicking it. However, this functio ...

Enhance user experience with AngularJS Bootstrap autocomplete feature by automatically filling input box when hovering over dropdown options

I am currently implementing the AngularJs Bootstrap typeahead functionality. Typically, when we enter text that matches an option, the dropdown list appears. https://i.stack.imgur.com/395Ec.png What I aim for is to automatically fill the textbox with the ...

How can you find the index of an HTML element while excluding any clearfix divs?

In the process of developing a CMS, I find myself in need of determining the index of the element I am currently working on. Consider the following stripped-down HTML structure: <div class="row"> <article class="col-md-4 col-sm-4 project" &g ...

Deactivate multiple input fields by utilizing various radio buttons

I need help with enabling and disabling input fields based on radio button selection. When the first radio button is selected, I want to disable three input fields, when the second is selected, only two specific input fields should be enabled (SHIFT START ...

Running a shell script on a website should always be done in a single instance

When I use html/php to call a bash script on a website, I have multiple html-buttons that initiate the same script with different arguments. The issue arises when each button click opens a new instance of the script. Is there a way to somehow resume the r ...

Tips for smoothly transitioning between two division elements:

I currently have two different div elements on my webpage: <div id="#content1"> <div id="divWelcome" style="margin-top:50px;"> <div id="headerimg" style="position: relative;"> <div style="position: absolute; bo ...

The $mdSticky feature in AngularJS Material seems to be malfunctioning

It's been a challenge for me to get the md-toolbar to stay in the top position. I decided to create a custom directive using the $mdSticky service in AngularJS. var app=angular.module('app',['ngMaterial']); app.controller(&apos ...

I am having trouble displaying my mysqli table correctly. I could use some help troubleshooting my code as I am unable to locate the error

After implementing Bootstrap, I am facing an issue with the table display on my new page. The code works perfectly fine on the old page, but for some reason, it's not showing correctly on the new one. Upon inspection, I suspect that mysqli_close and a ...

Utilizing mat dialog in conjunction with the bootstrap sticky top class to enhance functionality

I am encountering an issue where, upon clicking to delete an entry, a mat dialog should appear with everything else in the background greyed out. However, the problem I am facing is that when I attempt to delete an entry, the dialog appears but the sticky ...