固定大小的div

时间:2016-01-05 09:22:56

标签: html scroll fixed

我在div标签上添加了一个滚动条。但是,此窗口的大小会根据文本大小动态增长,因此滚动条将被禁用。

<?php namespace App;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class loginModel extends Model implements AuthenticatableContract, CanResetPasswordContract {

    use Authenticatable, CanResetPassword;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'frontend_users';

我想我需要修改窗口的大小,然后启用滚动条。这样对吗?如果是这样,我该怎么做?

2 个答案:

答案 0 :(得分:2)

您需要将div设为固定height。试试这个:

<div style="overflow:scroll;width: 650px; height:100px; font-size: 14px;margin-top: 50px;display:None" id="loader" class="tr-bg tr-internal-frame" onclick='$("#workNow").toggle()'></div>

这是一个Demo

答案 1 :(得分:1)

只需在div标签的css中设置height即可。 试试这段代码

div{
  border:1px solid black;
  height:100px; //ADD THIS
  width:100px;
  overflow:scroll;
}
<div>
a
b
c
c
d
e
f
g
h
i
j
k
l

m
o
p


z
.
.
.

</div>

相关问题