HTML / CSS中的按钮 /网格问题

发布于 2025-01-31 08:40:50 字数 108 浏览 2 评论 0原文

我对按钮的设置有问题。我不确定是否需要网格系统? 我希望它看起来像这个示例:

“我想要它的示例”

如果有人可以提供帮助,那么汉克斯就在Advanced中!

i have problems with the setup of the buttons. I'm unsure if i need a grid system or not?
I want it to look like this example:

example of how i want it

No code yet as i am unsure of where to start, and what to start with.

If somebody can help then hanks in advanced!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

要走干脆点 2025-02-07 08:40:50

您可以与flex,正当内容,对准目标一起使用,例如以下示例:

.wrapped {
 display: flex;
 flex-direction: column;
 align-items: center;
 width: 500px;
}

.avatar {
 width: 50px;
 height: auto;
}

button {
 width: 200px;
}

.div1 {
 display: flex;
 justify-content: center;
 padding: 10px;
}

.div2 {
 display: flex;
 flex-direction: column;
 padding: 10px;
}

.div2 button{
 width: 200px;
 margin: 6px;
 padding: 5px;
}

.div3 {
 display: flex;
 padding: 10px;
 margin-left: 0px;
 align-items: center;
}

.div3 button {
 width: 40px;
 height: 30px;
 margin-left: 160px;
}

.bell {
 width: 30px;
 padding: 10px;
 flex-basis: 1000px;
}
<section class="wrapped">
 <div class="div1">
  <button>At campus</button>
  <img class="avatar" src="https://media.istockphoto.com/vectors/user-icon-flat-isolated-on-white-background-user-symbol-vector-vector-id1300845620?k=20&m=1300845620&s=612x612&w=0&h=f4XTZDAv7NPuZbG0habSpU0sNgECM0X7nbKzTUta3n8=" />
 </div>
 <div class="div2">
  <button>Q & A</button>
  <button>Klasser</button>
  <button>Grupper</button>
  <button>Chat</button>
 </div>
 <div class="div3">
  <img class="bell" src="https://www.iconpacks.net/icons/1/free-bell-icon-860-thumb.png"/>
  <button>Help</button>
 </div>
 
</section>

You can use with flex, justify-content, align-items like example below:

.wrapped {
 display: flex;
 flex-direction: column;
 align-items: center;
 width: 500px;
}

.avatar {
 width: 50px;
 height: auto;
}

button {
 width: 200px;
}

.div1 {
 display: flex;
 justify-content: center;
 padding: 10px;
}

.div2 {
 display: flex;
 flex-direction: column;
 padding: 10px;
}

.div2 button{
 width: 200px;
 margin: 6px;
 padding: 5px;
}

.div3 {
 display: flex;
 padding: 10px;
 margin-left: 0px;
 align-items: center;
}

.div3 button {
 width: 40px;
 height: 30px;
 margin-left: 160px;
}

.bell {
 width: 30px;
 padding: 10px;
 flex-basis: 1000px;
}
<section class="wrapped">
 <div class="div1">
  <button>At campus</button>
  <img class="avatar" src="https://media.istockphoto.com/vectors/user-icon-flat-isolated-on-white-background-user-symbol-vector-vector-id1300845620?k=20&m=1300845620&s=612x612&w=0&h=f4XTZDAv7NPuZbG0habSpU0sNgECM0X7nbKzTUta3n8=" />
 </div>
 <div class="div2">
  <button>Q & A</button>
  <button>Klasser</button>
  <button>Grupper</button>
  <button>Chat</button>
 </div>
 <div class="div3">
  <img class="bell" src="https://www.iconpacks.net/icons/1/free-bell-icon-860-thumb.png"/>
  <button>Help</button>
 </div>
 
</section>

傾城如夢未必闌珊 2025-02-07 08:40:50

可以肯定的是,网格可以完美地适合您的设计。但是,您不需要明确的网格来获得该结果。 CSS Flexbox Display(显示:Flex)也可以正常工作,也许适合您的需求。甚至显示:块将起作用。

如果您需要仅由行或列组成的Web布局,则FlexBox是最适合使用的模型。但是,如果您有复杂的,多排和多列的布局,则需要使用CSS网格。

请查看更多详细信息:


​徽标和用户配置文件)在一个Div内。您可以使用显示:flex and flex方向:行在一行中显示它们,josify-content:space-bettent中间,因此元素填充了整个行。

然后您有4个按钮。您可以使用另一个DIV并将flex方向设置为。根据需要更改DIV和按钮的宽度。

基本上,最后一个div将与第一个相似。

对于每个div,您可以指定不同的宽度或高度。

for sure a grid would perfectly work for your design. However,you don't explicitly need a grid to obtain that result. Css flexbox display (display:flex) would also work and maybe fit your needs. Even display: block would work.

If you need a web layout that only consists of rows or columns, then Flexbox is the best model to use. However, if you have a complex, multi-row and multi-column layout, then you'll want to use CSS Grid.

Have a look for more details: https://www.webdesignerdepot.com/2018/09/grid-vs-flexbox-which-should-you-choose/


Here is a simple set-up for your design with flexbox in mind:

Suppose your first component (logo and user profile) are inside one div. You can use display:flex and flex-direction: row to display them in one line, and justify-content: space-between so the elements fill the entire row.

Then you have 4 buttons. You can use another div and set the flex-direction to column. Change the width of the div and of the buttons as you need.

Basically, the last div would be similar to the first one.

For each div you can specify different width or height.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文