How to make div width only to fit its content and the next div to fill the remainder?
you should put
The float
causes the element to occupy only its content
The overflow: hidden;
causes the next content to occupy the remaining space
.InputDivTitle{
float: left;
}
.InputDiv{
position: relative;
overflow: hidden;
}
see JSFiddle
Div is larger than its contents
you should write as below
The
line-height
property defines the amount of space above and below inline elements.
div.dataTables_paginate ul.pagination {
margin: 2px 0;
white-space: nowrap;
line-height: 10px;
}
Make div not affect other div's size
Change the inner div into a span that is display: inline-block;
. And move the styles of the outer div to the span. You can leave the margin.
<img src="/images/phatdeptrai.jpg" style="width: 28px;border-radius: 50%;float: left;clear: both;margin-left: 7px;margin-right: 7px;position: relative;top: 38px;">
<div style="float: left;max-width: 45%;">
<div style="font-size: .6875rem;color: #65676b;margin-left: 13px;margin-top: 10px;">Hoàng Phát đẹp trai</div>
<div style="margin-top: 2px;">
<span style="display: inline-block; padding: 7px 10px 7px 10px; color: black; background-color: #e4e6eb;border-radius: 20px;"> sas</span>
</div>
How can I make a div grow to fit its content, up to the max size of the parent container?
You can add flex to the modal, so that the content will not expand out of its parent (modal in this example):
.modal {
max-height: 70%;
border: 5px dashed green;
border-radius: 5px;
display: flex; /* Add this flex */
}
Related Topics
Why Is Percentage Height Not Working on My Div
Why Does This CSS Margin-Top Style Not Work
Understanding CSS Selector Priority/Specificity
How to Disable Browser Autocomplete on Web Form Field/Input Tags
Max Parallel Http Connections in a Browser
How to Style a Checkbox Using Css
Flexbox Code Working on All Browsers Except Safari. Why
How to Make a Div Not Larger Than Its Contents
How to Display Base64 Images in Html
How to Make an Element Width: 100% Minus Padding
Best Way to Center a ≪Div≫ on a Page Vertically and Horizontally
Css Margin Terror; Margin Adds Space Outside Parent Element
How to Make a Div 100% Height of the Browser Window
Make an HTML Number Input Always Display 2 Decimal Places
Setting Attribute Disabled on a Span Element Does Not Prevent Click Events