关于 bootstrap 崩溃的问题及其对 DOM 的影响
Issue regarding bootstrap collapse and it's effect on DOM
我在我的网页中使用 bootstrap。现在我想实现一个特定的 effect.I 有一个 div 和 class 名称 "container-fluid" 和 h2 标签下面有一个文本。就像下面这样:
<div class="container-fluid" style="background-color: #f8f8f8;text-align: center;height: 76px;">
<br>
<h2 id="mesheading" style="color: #a76281; font-size: 14px; cursor: pointer; margin-top: -4px; font-family: 'brandon_grotesquebold'; text-transform: uppercase; letter-spacing: 2px;">
Helping manufacturers save 20%-30% of the store cost
<span>
<button class="button_one" type="button" onclick="open_win_two()">
LEARN MORE
</button>
</span>
</h2><br>
</div>
我的要求是当浏览器window折叠时h2标签的字体变小。比如会变成10px.
并且在将浏览器 window 扩展到其实际大小时,它将移回其原始字体大小,即 14px
我对 jQuery 的崩溃相关事件做了很多研究。但这对我没有帮助。
所以请帮我实现这个。
提前致谢!!!
你应该像这样使用媒体查询的默认断点:
CSS
/* Extra Small Devices, Phones */
@media only screen and (min-width : 480px) {
.container-fluid h2 {
your font size
}
}
/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
.container-fluid h2 {
font-size: 10px;
}
}
/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
.container-fluid h2 {
your font size
}
}
/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
.container-fluid h2 {
your font size
}
}
问题
根据屏幕尺寸更改 css 元素。
解决方案
您可以使用媒体查询来更改 h2
或任何元素的字体大小。
例子
使用此媒体查询为您在查询中提供的两个宽度之间的任何内容设置条件。您可以重用它来创建多个场景,只需更改 min
和 max
width
的宽度即可。
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) {
.container-fluid h2 {
font-size: 10px;
}
}
然后在媒体查询之外,您可以将此作为任何不属于您的任何 media queries
.
条件的默认设置
.container-fluid h2 {
font-size: 14px;
}
针对特定设备
以下是针对流行设备的一些更常见的必要媒体查询。
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
@media only screen and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
/* Styles */
}
/**********
iPad 3
**********/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* Desktops and laptops ----------- */
@media only screen and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
@media only screen and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* iPhone 5 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6 ----------- */
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6+ ----------- */
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S3 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S4 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
/* Samsung Galaxy S5 ----------- */
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
我在我的网页中使用 bootstrap。现在我想实现一个特定的 effect.I 有一个 div 和 class 名称 "container-fluid" 和 h2 标签下面有一个文本。就像下面这样:
<div class="container-fluid" style="background-color: #f8f8f8;text-align: center;height: 76px;">
<br>
<h2 id="mesheading" style="color: #a76281; font-size: 14px; cursor: pointer; margin-top: -4px; font-family: 'brandon_grotesquebold'; text-transform: uppercase; letter-spacing: 2px;">
Helping manufacturers save 20%-30% of the store cost
<span>
<button class="button_one" type="button" onclick="open_win_two()">
LEARN MORE
</button>
</span>
</h2><br>
</div>
我的要求是当浏览器window折叠时h2标签的字体变小。比如会变成10px.
并且在将浏览器 window 扩展到其实际大小时,它将移回其原始字体大小,即 14px
我对 jQuery 的崩溃相关事件做了很多研究。但这对我没有帮助。
所以请帮我实现这个。
提前致谢!!!
你应该像这样使用媒体查询的默认断点:
CSS
/* Extra Small Devices, Phones */
@media only screen and (min-width : 480px) {
.container-fluid h2 {
your font size
}
}
/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
.container-fluid h2 {
font-size: 10px;
}
}
/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
.container-fluid h2 {
your font size
}
}
/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
.container-fluid h2 {
your font size
}
}
问题
根据屏幕尺寸更改 css 元素。
解决方案
您可以使用媒体查询来更改 h2
或任何元素的字体大小。
例子
使用此媒体查询为您在查询中提供的两个宽度之间的任何内容设置条件。您可以重用它来创建多个场景,只需更改 min
和 max
width
的宽度即可。
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) {
.container-fluid h2 {
font-size: 10px;
}
}
然后在媒体查询之外,您可以将此作为任何不属于您的任何 media queries
.
.container-fluid h2 {
font-size: 14px;
}
针对特定设备
以下是针对流行设备的一些更常见的必要媒体查询。
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
@media only screen and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {
/* Styles */
}
/**********
iPad 3
**********/
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* Desktops and laptops ----------- */
@media only screen and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
@media only screen and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : landscape) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation : portrait) and (-webkit-min-device-pixel-ratio : 2) {
/* Styles */
}
/* iPhone 5 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 568px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6 ----------- */
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 375px) and (max-device-height: 667px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* iPhone 6+ ----------- */
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 414px) and (max-device-height: 736px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S3 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 2){
/* Styles */
}
/* Samsung Galaxy S4 ----------- */
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 320px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
/* Samsung Galaxy S5 ----------- */
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : landscape) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}
@media only screen and (min-device-width: 360px) and (max-device-height: 640px) and (orientation : portrait) and (-webkit-device-pixel-ratio: 3){
/* Styles */
}