gpt4 book ai didi

html - 带 Bootstrap 的图像,打破列/格

转载 作者:太空宇宙 更新时间:2023-11-04 06:57:45 30 4
gpt4 key购买 nike

我构建了某种 CMS,但在使用 TinyMCE 和 Bootstrap 时遇到了一些问题。

我有一个页面,其中概述了一个 div,如果用户单击该 div,他们可以从模态中选择图像。该图像被插入到一个 tinymce 实例中,当用户点击“保存”时,它与 html(来自 tinymce)一起保存到数据库中,但它也被添加到 div 中以供预览。

我需要帮助找到一种方法来确保无论图像有多大,它都包含在 Bootstrap 列中。

空的 div:

enter image description here并在添加大图像后

enter image description here

我可以在此处的 html 中使用什么来进行引导,以确保即使在 tinyMce 中放置了一个巨大的图像,它也不会破坏 div?

<html>

<head>
<title>Template One</title>

<style type="text/css">
@import "style.css";
html,
body {
height: 100%;
overflow: hidden;
}

.modal-lg {
max-width: 80% !important;
}

.my-container {
display: flex;
flex-direction: column;
height: 100%;
}

.my-container>.top [class^="col-"],
.my-container>.bottom [class^="col-"] {
background-color: #929292;
color: white;
text-align: center;
}

.my-container>.middle {
flex-grow: 1;
padding: 30px;
background-size: cover;
}

.my-container>.middle>* {}

#clock {
/*background-color:#333;*/
font-family: sans-serif;
font-size: 40px;
text-shadow: 0px 0px 1px #fff;
color: #fff;
}

#clock span {
color: #fff;
font-size: 40px;
position: relative;
}

#date {
margin-top: -10px;
letter-spacing: 3px;
font-size: 20px;
font-family: arial, sans-serif;
color: #fff;
}

.buttonContainer {
display: flex;
flex-direction: column;
justify-content: center;
}
</style>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/css/gijgo.min.css" rel="stylesheet" type="text/css" />
<link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="src/ytv.css" type="text/css" rel="stylesheet" />

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.0/moment-with-locales.js"></script>
<script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/js/gijgo.min.js" type="text/javascript"></script>
<script type='text/javascript' src='//cdn.jsdelivr.net/jquery.marquee/1.4.0/jquery.marquee.min.js'></script>


</head>

<body>

<div class="container-fluid my-container">
<div class="row middle">
<div class="col-lg-6 leftFifty" id="leftFifty">
<div class="leftContent" style="background-color: white; height: 100%; border: dotted 1px black;">
<!-- This is the div that is clicked in to select an image -->
</div>
</div>
<div class="col-lg-6 rightFifty" id="rightFifty">
<div class="rightContent" style="background-color: white; height: 100%; border: dotted 1px black; ">
<!-- This is the div that is clicked in to select an image -->
</div>
</div>
</div>
</div>
</body>

</html>

最佳答案

实际上,您所要做的就是设置 width: 100%;高度可以是 auto 或完全省略以保持宽高比。

img {
width: 100%;
height: auto;
}
<html>

<head>
<title>Template One</title>

<style type="text/css">
@import "style.css";
html,
body {
height: 100%;
overflow: hidden;
}

.modal-lg {
max-width: 80% !important;
}

.my-container {
display: flex;
flex-direction: column;
height: 100%;
}

.my-container>.top [class^="col-"],
.my-container>.bottom [class^="col-"] {
background-color: #929292;
color: white;
text-align: center;
}

.my-container>.middle {
flex-grow: 1;
padding: 30px;
background-size: cover;
}

.my-container>.middle>* {}

#clock {
/*background-color:#333;*/
font-family: sans-serif;
font-size: 40px;
text-shadow: 0px 0px 1px #fff;
color: #fff;
}

#clock span {
color: #fff;
font-size: 40px;
position: relative;
}

#date {
margin-top: -10px;
letter-spacing: 3px;
font-size: 20px;
font-family: arial, sans-serif;
color: #fff;
}

.buttonContainer {
display: flex;
flex-direction: column;
justify-content: center;
}
</style>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/css/gijgo.min.css" rel="stylesheet" type="text/css" />
<link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="src/ytv.css" type="text/css" rel="stylesheet" />

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.0/moment-with-locales.js"></script>
<script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/js/gijgo.min.js" type="text/javascript"></script>
<script type='text/javascript' src='//cdn.jsdelivr.net/jquery.marquee/1.4.0/jquery.marquee.min.js'></script>


</head>

<body>

<div class="container-fluid my-container">
<div class="row middle">
<div class="col-lg-6 leftFifty" id="leftFifty">
<div class="leftContent" style="background-color: white; height: 100%; border: dotted 1px black;">
<img src="https://via.placeholder.com/600x250" />
<!-- This is the div that is clicked in to select an image -->
</div>
</div>
<div class="col-lg-6 rightFifty" id="rightFifty">
<div class="rightContent" style="background-color: white; height: 100%; border: dotted 1px black; ">
<!-- This is the div that is clicked in to select an image -->
</div>
</div>
</div>
</div>
</body>

</html>

关于html - 带 Bootstrap 的图像,打破列/格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52320790/

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