gpt4 book ai didi

javascript - 如何调整一个div属性使其可以根据内容展开

转载 作者:行者123 更新时间:2023-11-28 01:37:17 24 4
gpt4 key购买 nike

我正在制作一个包含多个部门的应用程序。在一个特定的部门中,内容不止一行。正如我们所知,它将使 div 可滚动以让我们看到内容。

但在这种情况下,我希望 div 根据内容调整其高度,以便一次性看到所有内容,并且不应该有滚动条......有什么办法吗??

HTML:

<!DOCTYPE html>
<html ng-app='myApp'>
<head>
<meta charset="ISO-8859-1">
<meta name="viewport" content="initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<title>Screen1</title>
<link rel="stylesheet" type="text/css" href="Screen1.css">
</head>
<body BGCOLOR="#e9ecf1" ng-controller='screen1Controller'>
<div class="main">
<div id="header1Main">
<div id="header1">Timeliness</div>
<div id="header2">

</div>
</div>
<div class="clear"></div>
<div class="opporMain">
<div class="opporHeader">
<div class="circleIcon">I</div>
<div class="opporHeading">Heading is the main thing that we need now it is a very important propert and wee need it we will have the thing according to the needs .........</div>
</div>
<div class="lineDiv"></div>
<div class="opporContent">
<div class="contentStatus">one three</div>
<div class="contentStatusDate">main thing</div>
<div class="clearContent"></div>
<div class="contentMainContent">"Things have been changed according to the needs"</div>
<div class="contentUpdateTime"><img src="images/timeline-3.png" alt="clock">&nbsp;Just Now</div>
<div class="clearContent"></div>
<div class="contentUpdateBy">updated by <font color="black">ziong zhu</font></div>
</div>
<div class="lineDiv"></div>
<div class="opporComment">
<img class="commentIcon" src="comment.png" alt="img"/>
<div class="opporCommentContent">Comments</div>
<div class="opporCommentDetails">3 Comments</div>
</div>
</div>


<div class="clearOppr"></div>


</div>



</div>
<script type="text/javascript" src="js/angular-1.0.1.js"></script>
<script src="js/application.js"></script>
<script src="js/Controller.js"></script>
</body>
</html>

CSS:

/*ROBOTO SLAB*/


@font-face {
font-family: 'RobotoSlab-bold';
src:url('fonts/RobotoSlab-Bold.woff') format('woff');
}

@font-face {
font-family: 'RobotoSlab-light';
src:url('fonts/RobotoSlab-Light.woff') format('woff');
}

@font-face {
font-family: 'RobotoSlab-regular';
src:url('fonts/RobotoSlab-Regular.woff') format('woff');
}

@font-face {
font-family: 'RobotoSlab-thin';
src:url('fonts/RobotoSlab-Thin.woff') format('woff');
}



/*ROBOTO*/

@font-face {
font-family: 'Roboto-regular';
src:url('fonts/Roboto-Regular-webfont.woff') format('woff');
}


@font-face {
font-family: 'Roboto-bold';
src:url('fonts/Roboto-Bold-webfont.woff') format('woff');
}


@font-face {
font-family: 'Roboto-thin';
src:url('fonts/Roboto-Thin-webfont.woff') format('woff');
}

@font-face {
font-family: 'Roboto-light';
src:url('fonts/Roboto-Light-webfont.woff') format('woff');
}

@font-face {
font-family: 'Roboto-medium';
src:url('fonts/Roboto-Medium-webfont.woff') format('woff');
}


body
{
margin:0px;
}
#header1Main
{
background-color:#ffffff;
overflow:auto;
}
#header1 {
display:inline-block;
font-family:Roboto-regular;
font-size: 12px;
color:#4f4f51;
height: 36px;
width:70%;
margin-left: 18px;
vertical-align: middle;
line-height: 36px;
float: left;
overflow: hidden;
}
#header2 {
display:inline-block;
margin-right:20%;
right:0px;
float:right;
margin-right: 14px;
vertical-align: middle;
line-height: 36px;

}
.img
{
height:15px;
width:15px;
}
.opporMain {

-webkit-box-shadow: 0px 1px 1px 1px rgba(194, 194, 194, 0.4);
-moz-box-shadow: 0px 1px 1px 1px rgba(194, 194, 194, 0.4);
box-shadow: 0px 1px 1px 1px rgba(194, 194, 194, 0.4);

/*-webkit-box-shadow: 1px 1px 2px 1px rgba(194,194,194,0.4);
-moz-box-shadow: 1px 1px 2px 1px rgba(194,194,194,0.4);
box-shadow: 1px 1px 2px 1px rgba(194,194,194,0.4);*/
margin-left:12px;
margin-right:12px;
}
.opporHeader {
clear:both;
position:relative;
display:inline-block;
display:block;
background-color:#ffffff;
overflow:auto;

min-height:40px;

}
.clear {
clear:both;
height:12px;
}
.clearOppr {
clear:both;
height:10px;
}
.circleIcon {
float:left;
display:inline-block;
width: 28px;
height: 28px;
margin-top:6px;
-wsebkit-border-radius: 14px;
-moz-border-radius: 14px;
border-radius: 14px;
background-color:#ffb400;
margin-left: 8px;
text-align: center;
font-family: Roboto-Light;
font-size:18px;
color:White;
vertical-align: middle;
line-height: 25px;
}
.opporHeading {
position: absolute;
float: right;
display: inline-block;
font-family: Roboto-bold;
font-weight: 700;
font-size: 14px;
column-rule: #000;231f20;
margin-top: 10px;
margin-left: 8px;
}
hr {
clear:both;
padding:0px;
margin:0px;
}
.lineDiv {
border-bottom: 1px solid #c2c2c2;


}
.opporContent {

background-color:#ffffff;
overflow:auto;

padding-bottom:12px;

}
.opporComment
{
height:30px;
background-color:#ffffff;
overflow:auto;

}
.contentStatus
{

display: inline-block;
float:left;
font-family:RobotoSlab-Regular;
font-weight:400;
font-size:13px;
color:#4554a5;
margin-top:10px;
margin-left:8px;

}
.contentStatusDate
{

display: inline-block;
float:left;
font-family:RobotoSlab-Bold;
font-size:13px;
font-weight:700;
color:#4554a5;
margin-top:10px;
margin-left:5px;

}
.contentMainContent
{
font-family:'RobotoSlab-Light';
font-weight: 300;
font-size:12px;
margin-top:8px;
margin-left:8px;
}
.clearContent
{
clear:both;
}
.contentUpdateTime
{

float:right;
font-family:Roboto-Light;
font-weight:100;
font-size:10px;
color:#b1b3b6;
margin-top:20px;
margin-right:10px;

}
.contentUpdateBy
{
float:right;
font-family:Roboto-Light;
font-size:12px;
font-weight:300;
color:#b1b3b6;
margin-top:4px;
margin-right:10px;

}

.opporCommentContent
{
display: inline-block;
float:left;
font-family: Roboto-Medium;
font-weight: 500;
font-size:12px;
margin-top:8px;
margin-left:6px;
color:#4f4f51;
}
.commentIcon
{
display: inline-block;
float:left;
margin-top:8px;
margin-left:8px;
}
.opporCommentDetails
{
float:right;
margin-top:8px;
margin-right:10px;
font-family: Roboto-Light;
font-size:12px;
color:#b1b3b6;
}

http://jsfiddle.net/tvaibhav/4ou13gts/

最佳答案

我已经更改了 .circleIcon.opporHeading 的 CSS:

.circleIcon {
position: absolute;
top: 0;
left: 0;
width: 28px;
height: 28px;
margin-top:6px;
-wsebkit-border-radius: 14px;
-moz-border-radius: 14px;
border-radius: 14px;
background-color:#ffb400;
margin-left: 8px;
text-align: center;
font-family: Roboto-Light;
font-size:18px;
color:White;
vertical-align: middle;
line-height: 25px;
}

.opporHeading {
display: inline-block;
font-family: Roboto-bold;
font-weight: 700;
font-size: 14px;
column-rule: #000;231f20;
margin-top: 8px;
margin-bottom: 8px;
padding-left: 45px;
}

JSFiddle:here

关于javascript - 如何调整一个div属性使其可以根据内容展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27637987/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com