Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Css expand Div to fit its content (Of other divs)

Posted on 2016-08-09
4
Medium Priority
?
79 Views
Last Modified: 2016-08-09
I have several divs inside each other. I have made an external div “s_GalleryFrame_Outer”, and want this div to expand to fit all its content. However, one of those divs contains a dynamic gallery. I have these images “float: left;” so as they fit responsively to the viewport. However, this is causing them to not display inside my main div. If I remove the float left, they simply stack one on top of the other.  
Any advice.
A
Css
.Js_GalleryFrame_Outer {
      background-color: #FFFFFF;
      border-radius: 9px;
      border-width: 2px;
      border-color: #FFFFFF;
      display: block;
      clear: both;
}
Js_GalleryClear {
      display: block;
      margin: auto;
}
.Js_OuterGallery {
      display: block;
      margin: auto;
}
.js_Gal-Pic {
      position: relative;
      background-size: auto 150px;
      background-repeat: no-repeat;
      min-height: 150px;
      float: left;
      margin-top: 4px;
      margin-right: 4px;
      margin-bottom: 4px;
      margin-left: 4px;
}


HTML
<div class="Js_GalleryFrame_Outer">
  <div class="">
        <h4 class="headline"><i class="fa fa-picture-o fa-2x" aria-hidden="true"></i>&nbsp;&nbsp;<%=strGalleryTitle%>aaaa</h4>
  </div>
 
  <div class="Js_GalleryClear">
        <p><%=strGalleryDesc%></p>
  </div>

        <div class="Js_OuterGallery">
        <%
        For IG_k = 0 to Ubound(ArrPicsToShow,2)
        If IG_k < 30 Then
        %>
        <div class="js_Gal-Pic" id="Js-Gal<%=ArrPicsToShow(0,IG_k)%>" style="background-image: url(<%=Code_GD_Protocol & strURL%>GalleryImages/<%=ArrPicsToShow(4,IG_k)%>);  "><a href="<%=Code_GD_Protocol & strURL%>GalleryImages/<%=ArrPicsToShow(4,IG_k)%>" rel="imagebox[Gallery]" class="thumbnailxx" title="<%=ArrPicsToShow(2,IG_k)%>">
            <img src="<%=Code_GD_Protocol & strURL%>VD_Generic_Images/gal-trans.gif" alt="<%=ArrPicsToShow(1,IG_k)%>" />
        </a>
        </div>    
        <%
        End If
        Next
        %>
        </div>
</div>
0
Comment
Question by:Abiel de Groot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 59

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 41748585
Add overflow:hidden to the outer frame
.Js_GalleryFrame_Outer {
      background-color: #FFFFFF;
      border-radius: 9px;
      border-width: 2px;
      border-color: #FFFFFF;
      display: block;
      overflow: hidden; /* ADD THIS */
}

Open in new window

Sample here
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 41748592
Another solution is to add this class (instead of the overflow: hidden)
.Js_OuterGallery:after {
	content: "";
	clear: left;
	display: table;
}

Open in new window

Sample here
0
 
LVL 5

Author Closing Comment

by:Abiel de Groot
ID: 41748612
Many thanks

A
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 41748623
You are welcome
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question