Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.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 对桌面选项卡和移动手风琴使用相同的代码-仅CSS_Html_Css - Fatal编程技术网

Html 对桌面选项卡和移动手风琴使用相同的代码-仅CSS

Html 对桌面选项卡和移动手风琴使用相同的代码-仅CSS,html,css,Html,Css,在小分辨率(手机)上,我需要将标签转换为手风琴。 这是当前的HTML: <main> <input id="tab1" type="radio" name="tabs" checked> <label for="tab1">Tab 1</label> <section id="content1">Tab 1 Content</section> <input id="tab2" type="radio"

在小分辨率(手机)上,我需要将标签转换为手风琴。 这是当前的HTML:

<main>
  <input id="tab1" type="radio" name="tabs" checked>
  <label for="tab1">Tab 1</label>
  <section id="content1">Tab 1 Content</section>

  <input id="tab2" type="radio" name="tabs">
  <label for="tab2">Tab 2</label>
  <section id="content2">Tab 2 Content</section>

  <input id="tab3" type="radio" name="tabs">
  <label for="tab3">Tab 3</label>
  <section id="content3">Tab 3 Content</section>
</main>
这在手机(如手风琴)上运行良好,但在桌面分辨率上,
标签
被破坏

你知道我如何在顶部水平固定标签吗?还需要有表格单元格显示


这是你问题的答案

main{
填充:50px;
保证金:0自动;
背景:#fff;
}
.塔巴区{
边框底部:1px实心#ccc;
}
部分{
显示:无;
填充:20px0;
位置:绝对位置
}
输入{
显示:无;
}
标签{
显示:内联块;
利润率:0-1px;
填充:15px 25px;
字号:600;
文本对齐:居中;
颜色:#bbb;
边框:1px实心透明;
}
标签:悬停{
颜色:#888;
光标:指针;
}
输入:选中+标签{
颜色:#555;
边框:1px实心#ddd;
边框顶部:2件纯色橙色;
边框底部:1px实心#fff;
}
#表1:选中~#内容1,
#表2:选中~#内容2,
#表3:选中~#内容3,
#表4:选中~#内容4{
显示:块;
}
@媒体屏幕和屏幕(最大宽度:650px){
标签{
/*字号:0*/
文本对齐:左对齐;
显示:块;
}
标签:之前{
保证金:0;
字号:18px;
}
部分{
位置:相对位置;
}
.塔巴区{
边界:无;
}
}
@媒体屏幕和屏幕(最大宽度:400px){
标签{
填充:15px;
}
}

表1
表1内容
表2
表2内容
表3
表3内容
表4
表4内容

无法使用
绝对值
,因为在选项卡下,我会有更多的内容,我刚刚找到了这个,并且可以使用
main {
  padding: 50px 0 0 0;
  margin: 0 auto;
  background: #fff;
}
section {
  display: none;
  padding: 20px 0 0;
  border-top: 1px solid #ddd;
}
input {
  display: none;
}
label {
  display: inline-block;
  margin: 0 0 -1px;
  padding: 15px 25px;
  font-weight: 600;
  text-align: center;
  color: #bbb;
  border: 1px solid transparent;
}
input:checked + label {
  color: #555;
  border: 1px solid #ddd;
  border-top: 2px solid orange;
  border-bottom: 1px solid #fff;
}
#tab1:checked ~ #content1,
#tab2:checked ~ #content2,
#tab3:checked ~ #content3 {
  display: block;
}
@media screen and (max-width: 650px) {
  main {
    padding-top:0;
  }
  label {
    /*font-size: 0;*/
    text-align:left;
    display:block;
  }
  label:before {
    margin: 0;
    font-size: 18px;
  }
}