Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使h2移动设备具有响应性?_Html_Css_Responsive - Fatal编程技术网

Html 如何使h2移动设备具有响应性?

Html 如何使h2移动设备具有响应性?,html,css,responsive,Html,Css,Responsive,我正在尝试实现以下目标,当屏幕大小为手机大小时,我希望我的HTML能够监听CSS中的类@media tag class.new“,我如何实现这一点 桌面CSS如下: h2{ font-size: 30px; } @media (max-width:600px) { .new { font-size: 24px; }} 移动设备CSS如下: h2{ font-size: 30px; } @media (max-width:600px) { .new { font-

我正在尝试实现以下目标,当屏幕大小为手机大小时,我希望我的HTML能够监听CSS中的类@media tag class.new“,我如何实现这一点

桌面CSS如下:

h2{
  font-size: 30px;
}
@media (max-width:600px) {
  .new {
  font-size: 24px;
  }}
移动设备CSS如下:

h2{
  font-size: 30px;
}
@media (max-width:600px) {
  .new {
  font-size: 24px;
  }}
我当前的html,我想我需要添加另一个div-wrap,即添加到html来覆盖它?不完全确定,请建议,如何让我的代码听。新类当它是一个手机大小如上

        <div class="list-group-item">
        <h2>HELLOWORLD
        <span class="glyphicon glyphicon-chevron-down"></span></h2>
        </div>

地狱世界
只需将
class=“new”
添加到您的
,如下所示:

<h2 class="new">HELLOWORLD <span class="glyphicon glyphicon-chevron-down"></span></h2>
HELLOWORLD
只需将
class=“new”
添加到您的
,如下所示:

<h2 class="new">HELLOWORLD <span class="glyphicon glyphicon-chevron-down"></span></h2>
HELLOWORLD
我将删除您的“新”类,并为
元素添加特定于媒体的CSS规则

更新

由于您不希望将此响应行为应用于所有
元素,因此可以使用一个类并使用该类定义CSS规则

下面是一个例子:

h2{
字体大小:30px;
}
@介质(最大宽度:600px){
h2.2响应性{
字体大小:24px;
}
}

地狱世界
我将删除您的“新”类,并为
元素添加特定于媒体的CSS规则

更新

由于您不希望将此响应行为应用于所有
元素,因此可以使用一个类并使用该类定义CSS规则

下面是一个例子:

h2{
字体大小:30px;
}
@介质(最大宽度:600px){
h2.2响应性{
字体大小:24px;
}
}

地狱世界

您为什么需要
.new
类?您不能在媒体查询中只针对
h2
吗?您针对的是
new
类,它在您提供的html中不存在
HELLOWORLD
为什么需要
.new
类?您不能在媒体查询中只针对
h2
吗?您针对的是
new
类,它在您提供的html中不存在
HELLOWORLD
我们可以添加完整答案吗?我是否将现有答案保留在HTML中,这次添加另一个@Waq无需。只需将该类添加到现有的
标记中。我们可以添加一个完整的答案吗?我是否将现有的保留在HTML中,这次添加另一个@Waq No need。只需将该类添加到现有的
标记中。它应该会起作用。H2用于其他地方。好的--我编辑了示例以利用类。H2用于其他地方。好的--我编辑了示例以利用类。