我想成为“黑人”的div。在调整浏览器大小时,它没有调整大小

发布于 2025-01-23 10:06:42 字数 760 浏览 0 评论 0原文

如何制作不调整浏览器大小的DIV调整大小? 该代码的div如下,还有其他7个类与紫色相同,但我希望黑色不与浏览器调整大小,我可以寻找什么可能的步骤

<div class="BLACK">
    <P>THIS IS BLACK DIV AND IT WILL NOT RESIZE WITH 
       BROWSER</P>
</div>
<div class="PURPLE">
    <p>THIS IS PURPLE DIV AND IT WILL RESIZE WITH BROWSER</p>
</div>


.BLACK
{
    background-color: black;
    background-size: contain;
    background-size: cover;
    font-size: fixed;
    height:20%;
    width:20%;
    display: block;
    margin-right: 30%;
    margin-top: 1%;
    padding-top: 9%;
    padding-bottom: 8%;
}

.PURPLE
{
    background-color: purple;
    height: 7%;
    padding-top: 0.05%;
    padding-bottom: 0.05%;
    margin-left: 20%;
    text-align: center;
}

how to make a div which do not resize with browser resize?
div for that code is as below there are other 7 classes same as purple but I want BLACK not to resize with browser what are possible steps I can look for

<div class="BLACK">
    <P>THIS IS BLACK DIV AND IT WILL NOT RESIZE WITH 
       BROWSER</P>
</div>
<div class="PURPLE">
    <p>THIS IS PURPLE DIV AND IT WILL RESIZE WITH BROWSER</p>
</div>


.BLACK
{
    background-color: black;
    background-size: contain;
    background-size: cover;
    font-size: fixed;
    height:20%;
    width:20%;
    display: block;
    margin-right: 30%;
    margin-top: 1%;
    padding-top: 9%;
    padding-bottom: 8%;
}

.PURPLE
{
    background-color: purple;
    height: 7%;
    padding-top: 0.05%;
    padding-bottom: 0.05%;
    margin-left: 20%;
    text-align: center;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

优雅的叶子 2025-01-30 10:06:42

div可以使用px单元固定大小,例如width:20px;width:300px;

<div class="BLACK">
  <p>THIS IS BLACK DIV AND IT WILL NOT RESIZE WITH BROWSER</p>
</div>
<div class="PURPLE">
  <p>THIS IS PURPLE DIV AND IT WILL RESIZE WITH BROWSER</p>
</div>
.BLACK {
  background-color: black;
  background-size: contain;
  background-size: cover;
  font-size: fixed;
  height: 300px;
  width: 350px;
  display: block;
  margin-right: 30%;
  margin-top: 1%;
  padding-top: 9%;
  padding-bottom: 8%;
}

.PURPLE {
  background-color: purple;
  height: 7%;
  width: 20%;
  padding-top: 0.05%;
  padding-bottom: 0.05%;
  margin-left: 20%;
  text-align: center;
}

div size can be fixed using px unit like width:20px; or width:300px;

<div class="BLACK">
  <p>THIS IS BLACK DIV AND IT WILL NOT RESIZE WITH BROWSER</p>
</div>
<div class="PURPLE">
  <p>THIS IS PURPLE DIV AND IT WILL RESIZE WITH BROWSER</p>
</div>
.BLACK {
  background-color: black;
  background-size: contain;
  background-size: cover;
  font-size: fixed;
  height: 300px;
  width: 350px;
  display: block;
  margin-right: 30%;
  margin-top: 1%;
  padding-top: 9%;
  padding-bottom: 8%;
}

.PURPLE {
  background-color: purple;
  height: 7%;
  width: 20%;
  padding-top: 0.05%;
  padding-bottom: 0.05%;
  margin-left: 20%;
  text-align: center;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文