首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >你能告诉我怎么写这个设计吗?

你能告诉我怎么写这个设计吗?
EN

Stack Overflow用户
提问于 2022-08-18 14:14:03
回答 2查看 99关注 0票数 1

我试图用HTML和CSS来编写这个设计。但我的结果和设计不一样。

这些文本及其背景不是正确的位置。我认为我的HTML元素结构是问题所在,而且可能也是CSS中的问题。你能告诉我怎么写代码才能得到和设计一样的结果吗?

代码语言:javascript
复制
.global_navigation_con {
  display: flex;
  width: 1100px;
  margin: 10px auto 31px;
}

.global_navigation_con div {
  position: relative;
  padding: 12px 0px 6px 77px;
  position: relative;
  line-height: 0px;
}

.global_navigation_con {
  background: url(https://via.placeholder.com/300);
}

.global_navigation_con div a {
  font-size: 2.1rem;
  line-height: 2.1rem;
  color: #333333;
  padding: 0px 40px 0px 0px;
}

.global_navigation_con div a span {
  padding: 0px 0px 0px 0px;
}

.global_navigation_con div:before {
  content: "";
  position: absolute;
  background: url(./detail-img/global_list.png) no-repeat;
  width: 22px;
  height: 40px;
  top: 0px;
  left: 36px;
}
代码语言:javascript
复制
<div class="global_navigation_con">
  <div>
    <a href="#"><span>トピックス</span></a>
  </div>
  <div>
    <a href="#"><span>区画情報</span></a>
  </div>
  <div>
    <a href="#"><span>立地企業</span></a>
  </div>
  <div>
    <a href="#"><span>企業支援</span></a>
  </div>
  <div>
    <a href="#"><span>福知山市と</span><span>その周辺</span></a>
  </div>
</div>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-08-18 16:03:17

我重新做了这件事,并尽可能地用flex属性来接近它。这也是移动第一。我也有这个你可以玩的科德芬

代码语言:javascript
复制
@charset "UTF-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  font-size: 16px;
}

ul {
  list-style: none;
}

a {
  text-decoration: none;
}

nav ul {
  display: flex;
  justify-content: space-evenly;
  flex-direction: column;
}
@media screen and (min-width: 600px) {
  nav ul {
    flex-direction: row;
  }
}
nav ul li {
  background: linear-gradient(to right, #E7E7E7, #FCFCFC);
  font-size: 1.5rem;
  color: white;
  padding: 0.5rem 1rem;
  position: relative;
}
@media screen and (min-width: 768px) {
  nav ul li {
    font-size: 2rem;
  }
}
@media screen and (min-width: 1024px) {
  nav ul li {
    font-size: 3rem;
  }
}

.overlay {
  display: flex;
  align-items: center;
  position: absolute;
  left: 1.2rem;
  top: 0.8rem;
  z-index: 10;
  color: black;
  font-size: 0.8rem;
}
@media screen and (min-width: 768px) {
  .overlay {
    top: 1.2rem;
    font-size: 1rem;
  }
}
@media screen and (min-width: 1024px) {
  .overlay {
    font-size: 1.5rem;
  }
}
.overlay::before {
  font: var(--fa-font-solid);
  content: "";
  margin-right: 0.5rem;
  color: #4880B5;
}
代码语言:javascript
复制
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" rel="stylesheet">

<nav>
  <ul>
    <li>
      Topics
      <a href="#" class="overlay">トピックス</a>
    </li>
    <li>
      Section
      <a href="#" class="overlay">区画情報</a>
    </li>
    <li>
      Location
      <a href="#" class="overlay">立地企業</a>
    </li>
    <li>
      Support
      <a href="#" class="overlay">企業支援</a>
    </li>
    <li>
      Unknown
      <a href="#" class="overlay">福知山市と</a>
    </li>
  </ul>
</nav>

票数 0
EN

Stack Overflow用户

发布于 2022-08-18 14:54:15

我已经尽我最大的努力用CSS网格进行了这个设计。我已经缩小了".grid_wrapper“类,只是为了堆栈溢出的目的,如果您自己使用的话,可以随意删除。

代码语言:javascript
复制
body{
    margin: 0;
    padding: 0;
    
}

.grid_container {
    width: 100%;

}

.grid_wrapper {
    justify-content: center;
    margin-top: 50px;
    margin-bottom: 50px;
    display: grid;
    grid-template-columns: repeat(4, 190px);
    grid-template-rows: repeat(2, 50px);
    grid-column-gap: 10px;
    grid-row-gap: 60px;
transform: scale(0.8);
}

.grid_item {
    background-image: linear-gradient(to right, #E7E7E7, #EAEAEA, transparent);
    display: flex;
    
}

.grid_item:hover {
    cursor: pointer;
}

i {
    color: rgb(73, 149, 211);
    font-size: 40px;
    margin-top: 5px;
    margin-left: 10px;
    position: absolute;
    z-index: 3;
}

.grid_itemtext {
    width:120px;
    font-size: medium;
    margin-top: 13px;
    margin-left: 40px;
    position: absolute;
    z-index: 2;
    text-decoration: underline;
    font-weight: 200;
}

.grid_itemtextback {
    position: absolute;
    z-index: 1;
    opacity: 0.8;
    color: white;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 100;
    font-size: 35px;
    margin-top: -8px;
    margin-left: 15px;
}


@media screen
and (max-device-width: 860px) {
.grid_wrapper {
    justify-content: center;
    margin-top: 50px;
    margin-bottom: 50px;
    display: grid;
    grid-template-columns: repeat(2, 150px);
    grid-template-rows: repeat(4, 60px);
    grid-column-gap: 10px;
    grid-row-gap: 5px;
}
}
代码语言:javascript
复制
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" rel="stylesheet"/>
    <div class="grid_container">
        <div class="grid_wrapper">
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">トピックス</h1><h2 class="grid_itemtextback">Topics</h2></div>
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">区画情報</h1><h2 class="grid_itemtextback">Section</h2></div>
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">立地企業</h1><h2 class="grid_itemtextback">Location</h2></div>
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">企業支援</h1><h2 class="grid_itemtextback">Support</h2></div>
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">福知山市と</h1><h2 class="grid_itemtextback">Are</h2></div>
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">その周辺</h1><h2 class="grid_itemtextback">English</h2></div>
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">その周辺</h1><h2 class="grid_itemtextback">English</h2></div>
        <div class="grid_item"><i class="fas fa-angle-right"></i><h1 class="grid_itemtext">その周辺</h1><h2 class="grid_itemtextback">English</h2></div>
        </div>
      </div>

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73404601

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档