Fresh가 포함된 블로그 엔진: 홈 메뉴 및 헤더
16602 단어 javascriptreactfreshwebdev
목차
Sokhavuth TIN ・ 8월 9일 ・ 2분 읽기
GitHub: https://github.com/Sokhavuth/deno-fresh
데노 배치: https://khmerweb-fresh.deno.dev
// components/front/home.jsx
/** @jsx h */
import { h } from "preact";
import Base from "../base.jsx";
function HomeJsx(props){
return(
<section class="Home">
<link href="/styles/front/home.css" rel="stylesheet" />
<script src="/scripts/menu.js"></script>
<header>
<div class="inner region">
<div class="title"><a href="/">{ props.data.setting.site_title }</a></div>
<form action="search" method="post">
<select class="category" name="frontSearch">
<option>Posts</option>
<option>Books</option>
</select>
<input type="text" name="q" required placeholder="Search" />
<input type="submit" value="Submit" />
</form>
<div class="login">
<a href="/login">Login</a> | <a href="#">Register</a>
</div>
</div>
</header>
<div class="menu">
<div class="inner region">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="/styles/front/menu.css" />
<div class="topnav" id="myTopnav" dangerouslySetInnerHTML={{__html: `
<a href="/" class="active">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
<a href="javascript:void(0);" class="icon" onclick="mobileMenu()">
<i class="fa fa-bars"></i>
</a>
`}}/>
</div>
</div>
</section>
)
}
export default function Home(props){
props.data.page = HomeJsx;
return(
<Base data={props.data} />
)
}
// static/scripts/menu.js
function mobileMenu(){
const x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
/* static/styles/front/menu.css */
.Home .menu{
background: #333;
}
.Home .menu .topnav {
background-color: #333;
overflow: hidden;
}
.Home .menu .topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 8px 16px;
text-decoration: none;
font-size: 17px;
}
.Home .menu .topnav a:hover {
background-color: #ddd;
color: black;
}
.Home .menu .topnav a.active {
background-color: #04AA6D;
color: white;
}
.Home .menu .topnav .icon {
display: none;
}
@media screen and (max-width: 600px) {
.Home .menu .topnav a:not(:first-child) {display: none;}
.Home .menu .topnav a.icon {
float: right;
display: block;
}
}
@media screen and (max-width: 600px) {
.Home .menu .topnav.responsive {position: relative;}
.Home .menu .topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.Home .menu .topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
Reference
이 문제에 관하여(Fresh가 포함된 블로그 엔진: 홈 메뉴 및 헤더), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/sokhavuth/blog-engine-with-fresh-home-menu-header-5509텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)