首页 > 解决方案 > 为什么我的网站的 CSS 代码在 bootstrap studio 中没有响应?

问题描述

我在 Bootstrap Studio 中使用 HTML 和 CSS 制作了我的网站

这是我的网站在 PC 上的样子: 这是我的网站在 PC 上的样子

当在移动设备上查看时,我尝试使用@media 来放大一个盒子:

.container_a {
  text-align: left;
  padding: 0px;
  padding-left: 0px;
  margin: 0px;
  padding-right: 0px;
  color: #fafafa;
  background: #000000;
  padding-bottom: 0px;
  border: 2.4px solid #999;
  border-top-left-radius: 7px;
  border-top-right-radius: 7px;
  height: 33%;
  width: 30%;
}

.container_a {
  position: absolute;
  top: 50%;
  left: 50%;
  -moz-transform: translateX(-50%) translateY(-50%);
  -webkit-transform: translateX(-50%) translateY(-50%);
  transform: translateX(-50%) translateY(-50%);
}

@media (min-width: 768px) {
  container_a {
    text-align: left;
    padding: 0px;
    padding-left: 0px;
    margin: 0px;
    padding-right: 0px;
    border-radius: 10 px;
    color: #fafafa;
    background: #000000;
    padding-bottom: 0px;
    border: 2.4px solid #999;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
    height: 33%;
    width: 30%;
  }
}

@media (min-width: 320px) and (max-width: 768px) {
  container_a {
    width: 80%;
    height: 35%;
  }
}

但它不起作用: 但它不起作用

为什么它不起作用?

标签: htmlcssresponsivemobile-websitebootstrap-studio

解决方案


这不能回答您的问题,因为它与拼写错误相关并且将被关闭,但是您确实可以将 CSS 减少到更易于管理的内容,因为您有一堆冗余代码:

.container_a {
  text-align: left;
  padding: 0;
  margin: 0;
  color: #fafafa;
  background: #000000;
  border: 2.4px solid #999;
  /* Shorthand for border-radius */
  border-radius: 7px 7px 0 0;
  position: absolute;
  top: 50%;
  left: 50%;
  /* combine into the translate shorthand */
  transform: translate(-50%, -50%);
  /* Put your mobile styles here */
  width: 80%;
  height: 35%;
}

@media (min-width: 768px) {
  .container_a {
    /* Only add the properties that change */
    height: 33%;
    width: 30%;
  }
}


推荐阅读