The div container fails to adjust its size to fit the text content in CSS

I am encountering an issue where the wrapper box does not adjust in size to fit the paragraph text. I attempted using height:auto;, but it did not resolve the problem.

If possible, could you provide examples with and without scrollbars? My primary concern is that the grey box does not expand properly. If scroll bars are necessary, I would prefer them to be on the p.desc.

You can view my jsfiddle here: http://jsfiddle.net/XxDFb/29/

HTML

<div class="team-wrapper">
    <div class="team-member-photo">
        <img alt="pic" src="http://placehold.it/134x108">
    </div>
    <div class="team-member-social-network-links">  <a class="url" href="http://www.repeatpenguin.com" title="repeatpenguin.com" rel="me">Twitter</a> / <a class="url" href="http://www.repeatpenguin.com" title="repeatpenguin.com" rel="me">Facebook</a>

    </div>
    <div class="team-details">
        <p class="name">Firstname Surname</p>
        <p class="job-title">Job title</p>
        <p class="email">Email Address</p>
        <p class="tel">112-123-1232</p>
        <p class="desc"><p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam quis elementum neque. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non facilisis magna. Vestibulum mattis vitae lacus vitae hendrerit. Maecenas vel urna et quam egestas bibendum. Mauris aliquet tellus ante, sit amet malesuada urna tincidunt id. In dapibus erat vel metus aliquet rhoncus.<... 

<p><strong>CSS</strong></p>

<pre><code>div.team-wrapper {
    background-color:#dedede;
    padding:10px;
    position:relative;
    height:auto;

}
div.team-member-photo {
    width:135px;
    height:109px;
    padding-top:20px;
    padding-left:20px;
}
div.team-member-photo img {
    background: none repeat scroll 0 0 #F1F1EF;
    border: 1px solid #B2B4B2;
    padding: 8px;
}
div.team-member-social-network-links {
    width:135px;
    height:109px;
    padding-left:30px;
    padding-top:20px;
}
div.team-details {
    top: 7px;
    left: 200px;
    position: absolute;
    border:1px solid RED;
    width:560px;
    margin-top:20px;
    height:auto;
}
div.team-details p {
    margin:0;
    line-height:25px;
}
div.team-details p.name {
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
    color: #4F688E;
    font-weight:700;
    font-size:18px;
    text-transform:uppercase;
}
div.team-details p.job-title {
    color: #626362;
    font-weight:400;
    font-size:18px;
    font:italic 16px/18px Georgia, Palatino, "Times New Roman", Times, serif;
}
div.team-details p.email {
    text-shadow:0 1px 1px rgba(255, 255, 255, 0.8);
    color: #626362;
}

div.team-details p.tel {
    color: black;
    font-weight:400;
    font-size:18px;
    font:16px/18px Georgia, Palatino, "Times New Roman", Times, serif;
}

div.team-details p.desc {
    padding-top:40px;
}

Answer №1

It seems like there may be a challenge with the CSS property position: absolute. When the element .team-details is set to absolute positioning, it loses its connection with the parent element. I have created a sample on this Fiddle to demonstrate.

To address this issue, I modified the class from .team-member-photo to .team-member-photo-social and relocated the social links within that container. Then, I removed the position: absolute property along with its associated styles.

Depending on your design needs, you can either use display: inline-block for the two divs to sit side by side while maintaining some spacing, or choose float: left. Floating elements in the parent may impact the height, so I included a class called .cf (clearfix) to ensure the parent extends to accommodate the children's heights.

In this case, I opted for using float because certain browsers like IE7 and earlier versions may not render inline-block correctly.

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

Blurring images with a combination of jQuery Backstretch and Blurjs

I have a background image displayed using Backstretch and want to apply Blur.js to blur elements on top of it. However, when I try to use Blur.js on the backstretched image, it doesn't work. I believe this is happening because Blur.js uses the CSS pro ...

"Troubleshooting a problem with a missing CSS background image

I have followed numerous tutorials, all of which provide the same instructions. I have specified my background within the body tag in my CSS style sheet, but for some reason, the page continues to display a blank white background. The image is located in t ...

New feature in Opencart 3.0.2: Adding items to cart exclusively for registered users!

Is there a way to restrict adding items to the cart only for registered users? For non-registered users, can we show an alert asking them to log in or register instead? I have tried implementing this code snippet in my controller/checkout/cart.php but it ...

"Customize your Vuetify v-card with uniquely styled rounded corners on only

I am seeking to create a unique v-card design where only two corners are rounded. Despite my attempts, the card ended up rotated by 90° and didn't achieve the desired outcome. DESIGN ATTEMPT: <div class="text-center rotate-ninety ml-n6" ...

Reasons for implementing attribute normalization in AngularJS

I am currently in the process of learning AngularJS through w3schools. The website offers a helpful example on creating custom directives, which can be found at Custom Directives. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/ang ...

Disable the countdown timer and hide the hours, minutes, and seconds once it reaches the

I am just starting to learn javascript and I'm struggling with removing the expired part of my countdown. When the countdown reaches 0 for days, hours, minutes, etc., I want it to display "Expired" instead. Below is the JavaScript code: var items = ...

Interactive pop-up text box for data cells in a table

I have implemented a textarea in the td cell of each row within column 3 to store description specific to that row. The goal is for the current description in the td's textarea to be copied over to the textarea located inside #div_toggle when the user ...

What's the best way to incorporate mouseenter() and mouseleave() into several elements sharing the same class?

I have a vision for a fun game where players must navigate from one platform to another without falling off the edges. The game starts when you hover over the initial platform, and success is achieved by reaching the final platform. However, failure occurs ...

How to retrieve the ID of a table column using jQuery in HTML

I am facing an issue with a HTML table that consists of only one row and one column: <table id="backlog"> <colgroup> <col width="200"></colgroup> <tbody> <tr><td id="91" tabindex="0" class="mark">BackLog&l ...

Step-by-step guide to setting up a responsive grid layout with automated scaling based on breakpoints for pairing cards with images and content side by side

After reading an article on Modern CSS grid solutions to common layout problems, I attempted to implement a two-way card layout as discussed. You can view the demo on Codepen here. However, when viewing on smaller screens, the paragraph text overlaps the ...

Difficulty executing for loop due to multiple buttons, resulting in malfunctioning buttons in JavaScript code

Currently encountering an issue while trying to implement modal windows on my first website. Everything works fine without the for loop, but I wanted to have multiple buttons and windows, so I decided to use a for loop to handle each button. Strangely, the ...

Header that sticks to the top of the page while the image slowly fades

Can anyone help me with my jsfiddle? I have a sticky header that shrinks when scrolling down, along with a png overlay that also shrinks. However, the current animation looks bad. I tried using fadeIn with jQuery but it's not working as expected. How ...

"Modifying the height of an SVG <g> element: A step-by

Is there a way to adjust the height of a g element? Trying to set the height using {params} but it's not responding I made some changes in the comments because the svg is quite large (Scene.js) {/* Transformation */} <g transform="trans ...

Avoid unnecessary extra margin on CSS div elements

Currently working with Bootstrap4. In a row with 2 col-md-6 (totaling 12 columns for the row). However, experiencing an unwanted margin on the left column as shown in the image below. How can I remove it? https://i.sstatic.net/u5oix.png html: <hea ...

Singularize button/solo in the center

How can I make this button align perfectly center on both PC and Mobile as a container? I have attempted the following CSS and HTML code: <section id="jour"> <div class="container"> <button class="btn1">Jeudi 12</button> ...

`Some Items Missing from Responsive Navigation Menu`

Hey there! I'm currently diving into the world of responsive design and I'm attempting to create a navigation bar that transforms into a menu when viewed on a mobile device or phone. Everything seems to be working fine, except that not all the na ...

What is the best method for enlarging the central image in Owl Carousel?

Could someone help me with implementing Owl Carousel to achieve this design? I have attempted it, but unfortunately, it is not working as expected. Your assistance in fixing the issue would be greatly appreciated. Please find the necessary code below: ...

How to position an SVG image directly next to text

Here is my JSFiddle with an SVG positioned to the left of some text inside a button. I am looking for a way to align the SVG vertically with the text within the button. I've considered a couple of methods: Trying to adjust the line-height, but that ...

Utilizing the Ternary Operator for conditional rendering in React is causing issues with HTML elements

Why does React display the "signin" div when the user is not true, but displays the children of the "user-profile" div inside the "signin" div when the user is true? I have tried multiple solutions to fix this issue, but it persists. If anyone knows how t ...

The autocomplete feature is situated quite a bit lower than the input box

One issue I am facing in my MVC Razor page is with the autocomplete functionality. When the textbox is first used, the autocomplete results appear below the textbox (as shown in this image), but on subsequent uses, it appears correctly directly below the t ...