【问题标题】:Circle-type changing the radius when using font size in mobile device在移动设备中使用字体大小时圆形改变半径
【发布时间】:2018-07-23 07:56:56
【问题描述】:

我正在使用圆形 (https://circletype.labwire.ca/) 进行文本轮转,它适用于桌面,但在移动设备中,它首先以默认字体大小显示,当我刷新浏览器时,它会显示我的实际字体大小。

例如:如果我第一次在移动设备中检查它会显示默认字体大小。如果我刷新浏览器,那么它会显示实际的字体大小。

如果我在媒体查询中设置字体大小,那么它也会改变文本的半径。

桌面

默认字体大小

当我刷新浏览器时

$(document).ready(function() {
  new CircleType(document.getElementById('header_text_round'))
    .radius(220);
});
  body {
  background-color: #000;
  color: #fff;
}

.header_wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  min-height: 100vh;
}

.header_section {
  height: 100%;
  min-height: 100%;
  width: 100%;
  position: fixed;
  z-index: -1;
}

.banner_bg {
  background-repeat: no-repeat;
  background-size: cover;
  width: 100%;
  height: auto;
  background-position: center;
  min-height: 100%;
}

.header_bg {
  position: relative;
  background-position: center;
}

.header_box_wrapper {
  width: 350px;
  box-sizing: border-box;
  position: absolute;
  top: 22%;
  right: 15%;
  color: #fff;
  transform: translateY(-50%);
}

@media all and (max-width:768px) {
  .mob_header_bg {
    background-image: url("https://lh4.ggpht.com/PbWVvAUJyNT_joymCCwbJCVwvM6JoyV2ogoqhhMT9ZDt4zPjff2Dn0jO8aMDPauwTh4=h900")!important;
  }
  h2#header_text_round {
    color: red !important;
    font-size: 22px !important;
    text-transform: uppercase;
  }
  body .header_box_wrapper {
    width: 100% !important;
    top: 20%;
    right: 0;
  }
}
<div class="header_wrapper">
  <div class="header_section">
    <div class="header_bg banner_bg mob_header_bg"></div>
    <div class="container">
      <div class="header_box_wrapper">
        <div class="header_box">
          <h2 id="header_text_round">Lorem ipsum dolor sit amet</h2>
        </div>
      </div>
    </div>
  </div>
</div>




<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://circletype.labwire.ca/dist/circletype.min.js"></script>

【问题讨论】:

  • @UllasHunka,您能告诉我您使用什么工具从代码中删除空格吗?
  • 当你使用sn-p时,左侧菜单上有一个叫tidy的按钮。
  • 感谢您的回复。你知道我的决心吗?
  • 抱歉,贴错了答案。
  • 您的媒体查询是否正确关闭?

标签: javascript jquery html css circletype


【解决方案1】:

您可以尝试的一个修复是在vw 中更新您的字体大小。我从 320 像素的分辨率检查了这个,它在横向和纵向上看起来都很好 767 像素。所以像下面这样更新 CSS 并告诉我

h2#header_text_round {
    color: red !important;
    font-size: 5vw !important;
    text-transform: uppercase;
  }

$(document).ready(function() {
  new CircleType(document.getElementById('header_text_round'))
    .radius(220);
});
  body {
  background-color: #000;
  color: #fff;
}

.header_wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  min-height: 100vh;
}

.header_section {
  height: 100%;
  min-height: 100%;
  width: 100%;
  position: fixed;
  z-index: -1;
}

.banner_bg {
  background-repeat: no-repeat;
  background-size: cover;
  width: 100%;
  height: auto;
  background-position: center;
  min-height: 100%;
}

.header_bg {
  position: relative;
  background-position: center;
}

.header_box_wrapper {
  width: 350px;
  box-sizing: border-box;
  position: absolute;
  top: 22%;
  right: 15%;
  color: #fff;
  transform: translateY(-50%);
}

@media all and (max-width:768px) {
  .mob_header_bg {
    background-image: url("https://lh4.ggpht.com/PbWVvAUJyNT_joymCCwbJCVwvM6JoyV2ogoqhhMT9ZDt4zPjff2Dn0jO8aMDPauwTh4=h900")!important;
  }
  h2#header_text_round {
    color: red !important;
    font-size: 5vw !important;
    text-transform: uppercase;
  }
  body .header_box_wrapper {
    width: 100% !important;
    top: 20%;
    right: 0;
  }
}
<div class="header_wrapper">
  <div class="header_section">
    <div class="header_bg banner_bg mob_header_bg"></div>
    <div class="container">
      <div class="header_box_wrapper">
        <div class="header_box">
          <h2 id="header_text_round">Lorem ipsum dolor sit amet</h2>
        </div>
      </div>
    </div>
  </div>
</div>




<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://circletype.labwire.ca/dist/circletype.min.js"></script>

【讨论】:

  • 感谢您的回复,正在更改手机中的半径
  • 您在移动设备中的半径是多少?您必须根据需要的半径调整 vw 中的字体大小
  • 我没有设置移动设备的半径。它将从插件中获取,但如果我更改字体大小,那么它也会更改半径。您可以在浏览器中签入您的代码。
  • 我不知道你在找什么半径..因为我们使用大众,它会根据分辨率改变..所以半径也是
  • 我在页面中添加了脚本来显示弯曲的电子文本。半径是220,如果我改变字体大小,那么它也会改变弯曲半径。 $(document).ready(function() { new CircleType(document.getElementById('header_text_round')) .radius(220); });
猜你喜欢
  • 1970-01-01
  • 2013-04-09
  • 2014-10-09
  • 1970-01-01
  • 1970-01-01
  • 2014-04-24
  • 2012-07-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多