水平导航栏与自定义的h1文本

huangapple go评论65阅读模式
英文:

Horizontal Naviation Bar with customized h1 text

问题

以下是您要翻译的部分:

"All I want is to put the icon in the left and let it be horizontally aligned with the title." = "我只想把图标放在左边,并让它与标题水平对齐。"

"Here is the CodePen: https://codepen.io/mrlima/pen/WNgoGew" = "这是CodePen链接:https://codepen.io/mrlima/pen/WNgoGew"

"I'm really new to front-end coding, I'm much better with Javascript Algorthims, please, be patient with me because English is my second language." = "我真的很新手前端编码,我在JavaScript算法方面更擅长,请谅解我,因为英语是我的第二语言。"

/*HTML*/
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Poise Idiomas</title>
	<link rel="stylesheet" href="css/style.css">
	<script src="https://kit.fontawesome.com/e424189c9b.js" crossorigin="anonymous"></script>
</head>

<body>
	<div class="topnav">
      <h1 id="title">
        <i style="float:left;" class="fa-solid fa-bars"></i>
        <span class="green">P</span><span class="yellow">O</span><span class="blue">I</span><span class="yellow">S</span><span class="green">E</span>
        <span class="fancy-canada-flag">Idiomas</span><span class="fancy" style="font-size:30pt;">.com</span>
      </h1>
  </div>
  <script src="script/script.js"></script>
</body>

</html>
/*CSS*/
@import url("https://fonts.googleapis.com/css2?family=Lobster&family=Tilt+Warp&display=swap");
:root {
  --bg-color: rgba(20, 20, 20, 1);
}
html, body {
  background-color: var(--bg-color);
  color: white;
  font-family: "Tilt Warp", cursive;
  margin:0px;
  padding:2px;
}
h1 {
  margin: 0px;
  padding: 0px;
}
::selection{
  background: transparent;
  color: #d12628;
}
.topnav{
  /* display:inline; */
}
#title {
  text-align:center;
  font-size: 6rem;
  color: #ef233c;
}
/* ------------------------------------------------------- */
.blue {color: #002776;}
.yellow {color: #ffdf00;}
.green {color: #009c3b;}
.white {color: #ffffff;}
.fancy{font-family: "Lobster";color:#d12628;}
.fancy-canada-flag {
  font-family: "Lobster";
  background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_(Pantone).svg/800px-Flag_of_Canada_(Pantone).svg.png');
  background-size: cover;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

/*No Javascript code written.*/
英文:

All I want is to put the icon in the left and let it be horizontally aligned with the title.
Here is the CodePen: https://codepen.io/mrlima/pen/WNgoGew

I'm really new to front-end coding, I'm much better with Javascript Algorthims, please, be patient with me because English is my second language.

/*HTML*/
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta charset=&quot;UTF-8&quot;&gt;
	&lt;title&gt;Poise Idiomas&lt;/title&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/style.css&quot;&gt;
	&lt;script src=&quot;https://kit.fontawesome.com/e424189c9b.js&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;div class=&quot;topnav&quot;&gt;
      &lt;h1 id=&quot;title&quot;&gt;
        &lt;i style=&quot;float:left;&quot;class=&quot;fa-solid fa-bars&quot;&gt;&lt;/i&gt;
        &lt;span class=&quot;green&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;yellow&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;blue&quot;&gt;I&lt;/span&gt;&lt;span class=&quot;yellow&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;green&quot;&gt;E&lt;/span&gt;
        &lt;span class=&quot;fancy-canada-flag&quot;&gt;Idiomas&lt;/span&gt;&lt;span class=&quot;fancy&quot; style=&quot;font-size:30pt;&quot;&gt;.com&lt;/span&gt;
      &lt;/h1&gt;
  &lt;/div&gt;
  &lt;script src=&quot;script/script.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;

&lt;/html&gt;



/*CSS*/
@import url(&quot;https://fonts.googleapis.com/css2?family=Lobster&amp;family=Tilt+Warp&amp;display=swap&quot;);
:root {
  --bg-color: rgba(20, 20, 20, 1);
}
html, body {
  background-color: var(--bg-color);
  color: white;
  font-family: &quot;Tilt Warp&quot;, cursive;
  margin:0px;
  padding:2px;
}
h1 {
  margin: 0px;
  padding: 0px;
}
::selection{
  background: transparent;
  color: #d12628;
}
.topnav{
  /* display:inline; */
}
#title {
  text-align:center;
  font-size: 6rem;
  color: #ef233c;
}
/* ------------------------------------------------------- */
.blue {color: #002776;}
.yellow {color: #ffdf00;}
.green {color: #009c3b;}
.white {color: #ffffff;}
.fancy{font-family: &quot;Lobster&quot;;color:#d12628;}
.fancy-canada-flag {
  font-family: &quot;Lobster&quot;;
  background-image: url(&#39;https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Flag_of_Canada_(Pantone).svg/800px-Flag_of_Canada_(Pantone).svg.png&#39;);
  background-size: cover;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

/*No Javascript code written.*/

答案1

得分: 1

以下是翻译好的内容:

第一件我想提到的事情是不要使用浮动(float),而是使用 flex 布局。
移除<i>标签中的浮动部分,将这些内容添加到 CSS 中。

#title {
    display: flex;
    align-items: center;
    text-align: center;
    font-size: 6rem;
    color: #ef233c;
}
.title_container {
    flex-grow: 1;
}

以下是 HTML 部分:

<h1 id="title">
    <i class="fa-solid fa-bars"></i>
    <div class="title_container">
        <span class="green">P</span><span class="yellow">O</span><span class="blue">I</span><span class="yellow">S</span><span class="green">E</span>
        <span class="fancy-canada-flag">Idiomas</span><span class="fancy" style="font-size: 30pt;">.com</span>
    </div>
</h1>

请查看我为此编写的 示例代码
水平导航栏与自定义的h1文本
1: https://codepen.io/Niloofar_araz/pen/MWqbjbE

英文:

The first thing that I want to mention is to not use float and use flex instead.
remove the float part in the <i> tag. add a div around the spans and add these to the CSS.

#title {
display: flex;
align-items: center;
text-align:center;
font-size: 6rem;
color: #ef233c;
}
.title_container{
flex-grow: 1;
}

and here is the HTML part

&lt;h1 id=&quot;title&quot;&gt;
    &lt;i class=&quot;fa-solid fa-bars&quot;&gt;&lt;/i&gt;
    &lt;div class=&quot;title_container&quot;&gt;
        &lt;span class=&quot;green&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;yellow&quot;&gt;O&lt;/span&gt;&lt;span 
class=&quot;blue&quot;&gt;I&lt;/span&gt;&lt;span class=&quot;yellow&quot;&gt;S&lt;/span&gt;&lt;span 
class=&quot;green&quot;&gt;E&lt;/span&gt;
        &lt;span class=&quot;fancy-canada-flag&quot;&gt;Idiomas&lt;/span&gt;&lt;span class=&quot;fancy&quot; 
style=&quot;font-size:30pt;&quot;&gt;.com&lt;/span&gt;
    &lt;/div&gt;
  &lt;/h1&gt;

look at the pen that I wrote for it.
水平导航栏与自定义的h1文本

huangapple
  • 本文由 发表于 2023年2月27日 01:54:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75573952.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定