html - 是否可以在不丢失响应能力的情况下以像素为单位设置一个部分的宽度,以百分比为单位设置剩余部分的宽度?

标签 html css responsive-design fixed

aside {
    background-color: blue;
    width: 220;
    list-style: none;
    height: 100%;
    float:left;
}

article {
    background-color: red;
    width:60%;
    height:100%;
    float: left;
}
        <aside>
            <ul>
                <li><a>1st item</a></li>
                <li><a>2nd item</a></li>
                <li><a>3rd item</a></li>
                <li><a>4th item</a></li>
            </ul>
        </aside>
            
        <article>
          <p>contents here</p>
        </article>

在上面的代码中,我尝试创建一个菜单部分和内容部分。 菜单部分的特点是即使调整窗口大小,它的宽度也保持不变。但是内容部分需要根据窗口调整大小。但是这里上面给出的设计不是响应式设计。是否可以设计这样的菜单和内容部分而不损失其响应性?

最佳答案

article 中删除 widthfloat 属性并添加 overflow: hidden

aside {
  background-color: blue;
  width: 150px;
  float:left;
}

aside ul {
  list-style: none;
}

article {
  background-color: red;
  overflow: hidden;
}
<aside>
  <ul>
    <li><a>1st item</a></li>
    <li><a>2nd item</a></li>
    <li><a>3rd item</a></li>
    <li><a>4th item</a></li>
  </ul>
</aside>
            
<article>
  <p>contents here</p>
</article>

关于html - 是否可以在不丢失响应能力的情况下以像素为单位设置一个部分的宽度,以百分比为单位设置剩余部分的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39873736/

相关文章:

html - 左 vs margin-left 和 CSS : position

javascript - 将动画插入到形状的 div 中

html - 为什么我的 h1 在桌面浏览器中的宽度与在 iPhone 上的宽度不同?

html - 响应式表单如何让文本框展开?

javascript - 如何使图像具有交互性?

html - 我如何在按钮菜单上添加声音

javascript - PHP-如何将 html 表格单元格值添加到 MYSQL 数据库

html - 部分彼此重叠

css - 在响应式 View 中对齐列表项

javascript - Chartjs.org 条形图无法正确缩放