我正在尝试从W3C
显示python
例外的模态框示例,异常字符串非常长,并且模态框体无法在一个屏幕中显示所有这些,并且模态页脚不能也显示(浏览器滚动条不会向下滚动),虽然为整个模态设置overflow: auto;
,代码就像,
function show_modal(row, column) {
var err;
var modal_header = $(".modal-header h2");
modal_header.text("header_txt");
var modal_body = $(".modal-body p");
// clear any previous contents
modal_body.text("");
var $pre = $("<pre>").html(err);
modal_body.append($pre);
var modal_footer = $(".modal-footer h3");
modal_footer.text("footer_txt");
modal.style.display = "block";
}
&#13;
.modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
padding-top: 100px;
/* Location of the box */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
/*height: 600px; !* Fixed height *!*/
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
/* Modal Content */
.modal-content {
position: relative;
background-color: #fefefe;
margin: auto;
overflow-y: scroll;
/*overflow: auto;*/
padding: 0;
border: 1px solid #888;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-webkit-animation-name: animatetop;
-webkit-animation-duration: 0.4s;
animation-name: animatetop;
animation-duration: 0.4s
}
/* Add Animation */
@-webkit-keyframes animatetop {
from {
top: -300px;
opacity: 0
}
to {
top: 0;
opacity: 1
}
}
@keyframes animatetop {
from {
top: -300px;
opacity: 0
}
to {
top: 0;
opacity: 1
}
}
/* The Close Button */
.close {
color: white;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 2px 16px;
background-color: #ff0000;
color: white;
}
/*.modal-body {*/
/*padding: 2px 16px;*/
/*}*/
pre {
white-space: pre-wrap
}
.modal-body {
width: 90%;
/*height: auto;*/
overflow-y: scroll;
margin: 1em auto;
padding: 0 1em;
border: 1px solid silver
}
.modal-footer {
padding: 2px 16px;
background-color: #ff0000;
color: white;
}
&#13;
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>modal header</h2>
</div>
<div class="modal-body">
<p>modal info</p>
</div>
<div class="modal-footer">
<h3>modal footer</h3>
</div>
</div>
</div>
&#13;
错误消息太长而无法放入编辑器中,因此就像
Traceback (most recent call last): File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 137, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 91, in create_connection raise err File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 81, in create_connection sock.connect(sa) File "/usr/local/lib/python3.5/dist-packages/gevent/_socket3.py", line 301, in connect raise error(err, strerror(err)) ConnectionRefusedError: [Errno 111] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen body=body, headers=headers) File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 353, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.5/http/client.py", line 1106, in request self._send_request(method, url, body, headers) File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request self.endheaders(body) File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders self._send_output(message_body) File "/usr/lib/python3.5/http/client.py", line 934, in _send_output self.send(msg) File "/usr/lib/python3.5/http/client.py", line 877, in send self.connect() File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 162, in connect conn = self._new_conn() File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 146, in _new_conn self, "Failed to establish a new connection: %s" % e) requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x7fca21d1b550>: Failed to establish a new connection: [Errno 111] Connection refused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/user_name/.local/lib/python3.5/site-packages/requests/adapters.py", line 376, in send timeout=timeout File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 609, in urlopen _stacktrace=sys.exc_info()[2]) File "/home/user_name/.local/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 273, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8087): Max retries exceeded with url: /ping (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fca21d1b550>: Failed to establish a new connection: [Errno 111] Connection refused',)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/user_name/PycharmProjects/project_service_probe/project_service_probe/project_core_services_probe.py", line 63, in core_services_probe r = self.service_probe(service) File "/home/user_name/PycharmProjects/project_service_probe/project_service_probe/project_core_services_probe.py", line 47, in service_probe self.project_services_config[service]["port"]) File "/home/user_name/PycharmProjects/project_service_probe/project_service_probe/project_core_services_probe.py", line 37, in ping_service return requests.get('http://{}:{}/ping'.format(host, port)) File "/home/user_name/.local/lib/python3.5/site-packages/requests/api.py", line 67, in get return request('get', url, params=params, **kwargs) File "/home/user_name/.local/lib/python3.5/site-packages/requests/api.py", line 53, in request return session.request(method=method, url=url, **kwargs) File "/home/user_name/.local/lib/python3.5/site-packages/requests/sessions.py", line 468, in request resp = self.send(prep, **send_kwargs) File "/home/user_name/.local/lib/python3.5/site-packages/requests/sessions.py", line 576, in send r = adapter.send(request, **kwargs) File "/home/user_name/.local/lib/python3.5/site-packages/requests/adapters.py", line 437, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8087): Max retries exceeded with url: /ping (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fca21d1b550>: Failed to establish a new connection: [Errno 111] Connection refused',))
那么如何正确添加滚动条以在模态体中显示内容,并在向下滚动页面时显示模态页脚。