figma下载_我如何使用Figma,CSS Grid和CSS Flexbox构建登录页面

figma下载

I enjoy looking at website designs that are on platforms like Behance, Dribble, etc. as they are visually very pleasing to the eye. While scrolling through these designs, I always wonder about one thing, that is, how difficult would it be to express these same designs as a code. The reason behind this curiosity is that I have come to realize that sometimes it is not easy to translate the design into its corresponding code. And when I say translation, I’m talking about the positioning of elements to be specific. There have been times while coding, I had to alter my design since it was difficult to represent the position of content in the original design. Also, from my personal experience, I can say that it is very frustrating to use tables, floats, positioning, and inline-block as all of these techniques miss out on a few major functionalities (vertical alignment, for example).

我喜欢在Behance,Dribble等平台上浏览网站设计,因为它们在视觉上非常令人愉悦。 在浏览这些设计时,我总是想知道一件事,即将这些相同的设计表示为代码有多困难。 这种好奇心背后的原因是,我已经意识到有时候将设计转换成相应的代码并不容易。 当我说翻译时,我指的是具体元素的定位。 有时在编码时,由于很难在原始设计中表示内容的位置,因此我不得不更改设计。 另外,根据我的个人经验,我可以说使用表,浮点数,定位和内联块非常令人沮丧,因为所有这些技术都缺少一些主要功能(例如,垂直对齐)。

For a recent personal project, I had to develop a landing page for a website. I had a rough idea regarding how I want the landing page to look and feel. My basic objective here was to replicate the design of the landing page which I will be doing beforehand, into a coded webpage version without any design compromises. While looking for an efficient way to build more design-oriented web pages, I came across CSS Grid and CSS Flexbox which are basically responsive layout models. These models not only allow us to tackle the positioning problem but also make the code easier to understand and maintain. Therefore, I decided to combine these two layout models along with my knowledge of working with Figma, which is an amazing online website design tool and this article explains that process.

对于最近的个人项目,我必须开发一个网站的登录页面。 我对目标网页的外观和感觉有一个大概的了解。 我的基本目标是将我将要预先进行的目标网页设计复制到编码的网页版本中,而不会进行任何设计折衷。 在寻找一种有效的方法来构建更多面向设计的网页时,我遇到了CSS Grid和CSS Flexbox,它们基本上是响应式布局模型。 这些模型不仅使我们能够解决定位问题,而且使代码更易于理解和维护。 因此,我决定将这两种布局模型与我与Figma一起工作的知识相结合,这是一个了不起的在线网站设计工具,本文将对此过程进行说明。

怎么了 (What’s the flow?)

  1. Design the landing page using Figma.

    使用Figma设计登录页面。
  2. Use CSS Grid to setup a parent grid.

    使用CSS网格设置父网格。
  3. Use CSS Flexbox to position the content.

    使用CSS Flexbox定位内容。

如何开始? (How to start?)

设计布局 (Design the layout)

First things first, I created the design in Figma. It has a pre-built website frame, which is like a blank canvas and a good place to start.

首先,我在Figma中创建了设计。 它有一个预建的网站框架,就像一块空白的画布,是一个很好的起点。

As I had decided that I am going to use CSS Grid, I knew that it divides the web page into rows and columns. Therefore, it would be practical to carry out the same division while designing by dividing the layout into three basic row sections which are present in almost all websites i.e. a header, a body, and a footer.

当我决定要使用CSS Grid时,我知道它会将网页分为行和列。 因此,在进行设计时,通过将布局划分为三个基本行部分(在几乎所有网站中都存在),即页眉,正文和页脚,进行相同的划分是可行的。

Image for post

My rule was to distribute the content into different possible rows and columns as it will make every element independent of each other. This will lead to more number of cells for more number of elements but will guarantee more positioning ease. So keeping that in mind, I initially divided the header section into two columns.

我的规则是将内容分配到可能的不同行和列中,因为它将使每个元素彼此独立 。 这将导致更多单元的数量更多的单元,但将保证更多的定位便利性。 因此请记住,我最初将标题部分分为两列。

Image for post

But I wanted to maintain some spacing between each element for consistency purposes. Also, the Hamburger menu, which is much of an icon representing an inactive section, does not need much space. That’s why having 3 varying columns instead of 2 would be a better choice.

但是我想在每个元素之间保持一定的间隔,以实现一致性。 此外,“汉堡包”菜单(大部分是代表不活动部分的图标)不需要太多空间。 这就是为什么使用3个不同的列而不是2个列会是一个更好的选择的原因。

Image for post

Now there are two things that I kept in mind going forward with this design strategy:

现在,在此设计策略中我要牢记两件事:

  • Spacing between cells

    单元格之间的间距
  • Size of the cells with respect to its content(elements).

    单元格相对于其内容(元素)的大小。

Next, I divided the Body section into different rows and columns.

接下来,我将“正文”部分划分为不同的行和列。

Image for post

left_space and right_space are blank columns that are present to provide a feel of center alignment. Footer section will also be divided into 3 columns which is similar to the header section.

left_space和right_space是空白列,用于提供中心对齐的感觉。 页脚部分也将分为三列,与页眉部分相似。

Image for post

Now after laying out the landing page design in terms of grids, the next thing to do was to layout the content with respect to the background of the web page.

现在,在以网格的形式对着陆页设计进行了布局之后,接下来要做的就是相对于网页背景来布局内容。

The hierarchy of the web page is logically in the following form:

该网页的层次结构在逻辑上采用以下形式:

  1. Web page has a Background

    网页有背景
  2. Grid goes on top the Background

    网格位于背景的最上方
  3. Content is laid out on the grid

    内容排列在网格上

The dependency between background and the grid is decided by what comes first. In my process, I preferred the grid to be laid out first and then the background under it. I grabbed a background image from Pexels and then resized and positioned it according to the grid on the web page.

背景和网格之间的依赖关系由先到者决定。 在我的过程中,我更喜欢先布局网格,然后再布局其下方的背景。 我从Pexels抓取了一个背景图像,然后根据网页上的网格对其进行了调整大小和定位。

Image for post

Now it was time to lay out the content using the designed grid system.

现在是时候使用设计的网格系统对内容进行布局了。

Lesson learned: Use standard alignments i.e. left, center and right for approximate positioning. Then precisely position the content using padding and/or margins.

经验教训:使用标准对齐方式,即左,中和右进行近似定位。 然后使用填充和/或边距精确定位内容。

As the content is going to be inside different cells, it can have different positions. And this requirement can be fulfilled by Flexbox. My major objective behind using Flexbox inside cells was to use it’s pre-built position attributes which can be used for alignment.

由于内容将位于不同的单元格中,因此可以具有不同的位置。 Flexbox可以满足此要求。 在单元格内部使用Flexbox的主要目的是使用其可用于对齐的预先建立的位置属性。

Image for post

If you observe each part of the content, it is approximately either on the left or right or in the center in each cell. This will make it easier to mimic the design in the coding phase.

如果您观察内容的每个部分,则大约在每个单元格的左侧或右侧或中心。 这将使在编码阶段模仿设计变得更加容易。

下一步是什么 ? (What’s next ?)

编码布局 (Code the layout)

As mentioned earlier I am going to require two things to bring the design to life.

如前所述,我将需要两件事来使设计栩栩如生。

  • CSS Grid

    CSS网格
  • CSS Flexbox

    CSS Flexbox

For CSS grid, there are some concepts that are required to be familiar with beforehand, so if you have not looked up Grids before, I urge you to take this tutorial or watch this. I’m going to mention some of the few concepts which I have used in this project:

对于CSS网格,需要事先熟悉一些概念,因此,如果您以前没有查阅Grids,我敦促您 阅读 教程 或观看 教程 我将提到在这个项目中使用的一些概念:

  • grid-template-columns/grid-template-rows

    网格模板列/网格模板行

Defines the columns and rows of the grid with a space-separated list of values. The values represent the track size, and the space between them represents the grid line. The fr unit allows you to set the size of a track as a fraction of the free space of the grid container.

用空格分隔的值列表定义网格的列和行。 这些值表示轨道大小,它们之间的间隔表示网格线。 fr单位允许您将轨道的大小设置为网格容器的可用空间的一部分。

.container {
grid-template-columns: ... | ...;
grid-template-rows: ... | ...;
}
  • grid-template-areas

    网格模板区域

Defines a grid template by referencing the names of the grid areas which are specified with the grid-area property. Repeating the name of a grid area causes the content to span those cells.

通过引用使用grid-area属性指定的网格区域的名称来定义网格模板。 重复网格区域的名称会使内容跨越这些单元格。

.container {   
grid-template-areas:
" | . | none | ..."
"...";
}
  • grid-area

    网格区域

Gives an item a name so that it can be referenced by a template created with the grid-template-areas property.

给项目命名,以便可以通过使用grid-template-areas属性创建的模板引用该项目。

.item {   
grid-area: <name> | <row-start> / <column-start> / <row-end> / <column-end>;
}

Firstly, let’s setup the grid structure in HTML

首先,让我们在HTML中设置网格结构

<div class="grid-container">
<div class="header">
<div class="header1">Head1</div>
<div class="header2">Head2</div>
<div class="header3">Head3</div>
</div>
<div class="left_space">Left_Space</div>
<div class="main">
<div class="main1">Main1</div>
<div class="main2">Main2</div>
<div class="main3">Main3</div>
</div>
<div class="right_space">Right_Space</div>
<div class="footer">
<div class="footer1">Footer1</div>
<div class="footer2">Footer2</div>
<div class="footer3">Footer3</div>
</div>
</div>

Here the header section is divided into 3 parts i.e. three columns: header1, header2 and header3. Further the body section contains three rows: main1, main2 and main3 and two columns: left_space and right_space. left_space and right_space are just space fillers to force the focus to the center of the page. Footer section is divided into three columns: footer1, footer2 and footer3.

在此,标题部分分为3部分,即三列:header1,header2和header3。 此外,主体部分包含三行:main1,main2和main3,以及两列:left_space和right_space。 left_space和right_space只是用于将焦点强制到页面中心的空格。 页脚部分分为三列:页脚1,页脚2和页脚3。

Now it was time to bring in some CSS

现在是时候引入一些CSS了

  • Header Section

    标头部分
.header{ 
grid-area: header;
display:grid;
grid-template-columns: 2fr 2fr 2fr 2fr;
grid-template-areas:
'header1 header2 header2 header3';
grid-gap: 10px;
}
.header1{ grid-area:header1;}
.header2{ grid-area:header2; }
.header3{ grid-area:header3; }
  • Body Section

    身体部分
.left_space{}
.main{
grid-area: main;
display:grid;
grid-template-rows: 3fr 3fr 1fr;
grid-template-areas:
'main1'
'main2'
'main3';
grid-gap: 10px;
}
.right_space{}
.main1{ grid-area:main1; }
.main2{ grid-area:main2; }
.main3{ grid-area:main3; }
  • Footer Section

    页脚部分
.footer{ 
grid-area: footer;
display:grid;
grid-template-columns: 9fr 1fr 1fr;
grid-template-areas:
'footer1 footer2 footer3';
grid-gap: 10px;
}
.footer1 { grid-area: footer1; }
.footer2 { grid-area: footer2; }
.footer3 { grid-area: footer3; }
  • Root grid-container

    根网格容器
.grid-container {
display: grid;
grid-template-rows: 1fr 6fr 1fr;
grid-template-areas:
'header header header header'
'left_space main main right_space'
'footer footer footer footer';
grid-gap: 10px;
padding: 10px;
height:100vh;
overflow: hidden;
}

After the grid was built, it was time to work inside each cell of the grid along with the content positioning. This was the most fun part of the process. This is where CSS Flexbox came into picture.

构建网格之后,是时候在网格的每个单元中进行工作以及进行内容定位了。 这是该过程中最有趣的部分。 这就是CSS Flexbox出现的地方。

For CSS Flexbox, there are some concepts which are required to be familiar with beforehand, so if you have not looked up Flexbox before, I urge you to take this tutorial or watch this. I’m going to mention some of the few concepts which I have used in this project:

对于CSS Flexbox,需要事先熟悉一些概念,因此,如果您以前没有看过Flexbox,我强烈建议您 阅读 教程 或观看 教程 我将提到在这个项目中使用的一些概念:

  • flex-direction

    弹性方向

This establishes the main-axis, thus defining the direction flex items are placed in the flex container.

这样便建立了主轴,从而确定了将柔韧性商品放置在柔韧性容器中的方向。

.container {
flex-direction: row | row-reverse | column | column-reverse;
}
  • justify-content

    证明内容

This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow the line.

这定义了沿主轴的对齐方式。 当一行中的所有伸缩项目都不灵活或已达到最大大小时,它可以帮助分配剩余的剩余可用空间。 当项目溢出线时,它还对项目的对齐方式施加一些控制。

.container {
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe;
}
  • align-items

    对齐项目

This defines the default behavior for how flex items are laid out along the cross axis on the current line. Think of it as the justify-content version for the cross-axis (perpendicular to the main-axis).

这定义了弹性项目如何沿当前行的横轴布置的默认行为。 可以将其视为跨轴(垂直于主轴)的证明内容版本。

.container {
align-items: stretch | flex-start | flex-end | center | baseline | first baseline | last baseline | start | end | self-start | self-end + ... safe | unsafe;
}

As I have positioned the content elements using standard alignment techniques in the design, I was able to directly make use of Flexbox attributes “justify-content” and “align-items” to quickly position the elements exactly mimicking the design :)

当我在设计中使用标准对齐技术定位了内容元素时,我能够直接利用Flexbox属性“ justify-content”和“ align-items”来快速定位与设计完全相似的元素:)

This was similar to positioning elements according to x-axis and y-axis.

这类似于根据x轴和y轴定位元素。

Header Section

标头部分

<!-- HTML -->
<div class="header2">Alphonso</div>/* CSS */
.header2 {
grid-area: header2;
display: flex;
justify-content: centre; //Vertical alignment
align-items: centre; //Horizontal alignment
}
Image for post
Image for post
Before vs After
之前与之后

Body Section

身体部分

<!-- HTML -->
<div class="main1">
<h2>Enjoy</h2>
<h3>Luxury</h3>
</div><div class="main3">
<p>Contrary to popular belief, Lorem Ipsum... </p>
</div>/* CSS */
.main1 {
grid-area: header2;
display: flex;
flex-direction: column;
justify-content: flex-start; //Vertical alignment
align-items: flex-end; //Horizontal alignment
color: #fff;
margin: 20px;
}.main3 {
grid-area: main3;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
margin: 20px;
}
Image for post
Image for post
Before vs After
之前与之后

So finally I got something like this,

所以最后我得到了这样的东西

Image for post
Image for post
With Grids vs Without Grids
有网格与无网格

Another advantage of combining Grids and Flexbox together is its flexibility to be responsive. With the help of media queries, it is quite easy to just change the structure of grid with respect to the size of the screen.

将Grids和Flexbox结合在一起的另一个优势是响应能力的灵活性。 在媒体查询的帮助下,相对于屏幕大小更改网格的结构非常容易。

This is not the only technique to use for developing landing pages but it is something that I figured out while going through the process myself. And like every other process this may also have some flaws but in the end, it worked out well for me. That’s why I decided to share my experience through this post.

这不是用于开发目标网页的唯一技术,而是我自己完成此过程时发现的技术。 像其他所有过程一样,这可能也有一些缺陷,但最后,对我来说效果很好。 这就是为什么我决定通过这篇文章分享我的经验的原因。

Thank you for giving it a read :)

谢谢您的阅读:)

完整代码可在我的GitHub上找到 (Full code available on my GitHub)

翻译自: https://uxdesign.cc/how-i-used-figma-css-grid-and-css-flexbox-to-build-a-landing-page-be861f397fee

figma下载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/274666.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

2022年Web平台的新动态

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

【逃离一线】被裁后的面经与感慨

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

使命召唤ios_使命召唤的精巧UI:战地

使命召唤iosWith over 50 million players worldwide it’s safe to say Warzone has become a global sensation. Featuring cross-platform play, multiple game modes, customisation and wealth of features too long to mention here — it’s captured its audience and …

深入浅出 package.json,目测大多数人不了解它

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

鲸鱼网络连接_登陆鲸鱼:在网络上读书,第1部分

鲸鱼网络连接I don’t know when it was I started using the text of Moby Dick in my workshops and talks. Likely it dates back to some of my earliest explorations of web typography. Since it’s out of copyright, it’s one those texts you can find online in va…

2022年值得使用的 Node.js 框架

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

更改apk安装包对android系统等级要求

此篇文章解决的为问题: █问题1.系统等级与apk等级不匹配. █问题2.更改api等级后的签名问题. 1.工具准备: 解压缩tool.zip文件夹: 2.开始反编译apk安装包 3.切换目录到tool目录下: 4.反编译: apktool.bat d 待编译apk目录名 存放编译后的文件目录 apktool.bat d Onenote_v14.…

推荐一个前端技术选型神器!真好用~

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

静态原型设计 加载中_见解1:原型设计有助于填补静态设计留下的空白。

静态原型设计 加载中In April 2015, I joined the Disney Parks creative team to design mobile experiences for the happiest place on Earth. I learned a lot from a diverse group of humble, creative, and smart people.2015年4月&#xff0c;我加入了迪士尼公园创意团…

最优资产组合步骤_重新设计投资组合网站之前,请按照以下5个步骤进行操作

最优资产组合步骤The portfolio website is one of the most important assets for a designer. Without it, it can be tough to find your next job or client.作品集网站是设计师最重要的资产之一。 没有它&#xff0c;很难找到下一份工作或客户。 The temptation is high …

裁员潮之下,13次面试拿下字节前端岗offer!

|前言很多粉丝私信&#xff0c;这两个月求职没有往年那么好跳&#xff0c;还有不少粉丝已经收到公司的“优化”通知下面分享一位粉丝的最近的面试经历&#xff0c;在疫情裁员潮的环境下&#xff0c;经历了成长、膨胀、闭关打磨等一系列的跌宕起伏&#xff0c;最终拿下字节总包5…

hdu 1754/zstu 3121 I Hate It(线段树)

http://acm.hdu.edu.cn/showproblem.php?pid1754 http://acm.zstu.edu.cn:8080/JudgeOnline/showproblem?problem_id3121 &#xff08;1&#xff09;线段树的基本操作&#xff1a;建树&#xff0c;查询&#xff0c;更新。 &#xff08;2&#xff09;重新写一遍时&#xff0c;…

sketch放入app组件_使用Sketch App设计CSS网格

sketch放入app组件首先定义您的网格 (Start by defining your grid) Sketch has 2 built-in layout features — Layout and Grid. In most cases, layout is a great way to organize content on a typical website utilizing a 12 column grid. However for this exercise we…

鲜为人知的CSS实用技巧

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

猎鹰spacex_我如何重新创建SpaceX仪表板UI

猎鹰spacexA couple of weeks ago, SpaceX Crew Dragon launched from Kennedy Space Center to transport astronauts Robert L. Behnken and Douglas G. Hurley to the ISS. Lots of things were revolutionary about this launch, but the one that caught my attention was…

Base64 编码原来这么简单

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

spring事物 设计模式_是什么使事物变得美丽,以及如何在设计中使用它

spring事物 设计模式What do you think about the phrase “beautiful design”? You like it, don’t care or does it make you wince?w ^帽子你想想那句“美丽的设计”&#xff1f; 您喜欢它&#xff0c;不在乎还是让自己畏缩了&#xff1f; For many, “beautiful” is …

历时一个月!50+Vue经典面试题详解,值得收藏!

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…

页面滚动时触发图片逐帧播放_如何在滚动效果上创建逐帧运动图像

页面滚动时触发图片逐帧播放A step by step guide on how to create that dynamic image background you see everywhere.有关如何创建随处可见的动态图像背景的逐步指南。 内容 (Content) Introduction 介绍 Result demo 结果演示 Prerequisite 先决条件 Step by step guide …

前端监控的搭建步骤,别再一头雾水了!

大家好&#xff0c;我是若川。持续组织了8个月源码共读活动&#xff0c;感兴趣的可以 点此加我微信ruochuan12 参与&#xff0c;每周大家一起学习200行左右的源码&#xff0c;共同进步。同时极力推荐订阅我写的《学习源码整体架构系列》 包含20余篇源码文章。历史面试系列。另外…