>  기사  >  웹 프론트엔드  >  뉴스 웹사이트 홈페이지 구축

뉴스 웹사이트 홈페이지 구축

PHPz
PHPz원래의
2024-09-01 20:31:42784검색

Build a News Website HomePage

소개

안녕하세요, 개발자 여러분! 저의 최근 프로젝트인 뉴스 홈페이지 웹사이트를 공유하게 되어 기쁩니다. 이 프로젝트는 최신 헤드라인과 기사를 보여주는 깔끔하고 기능적인 뉴스 웹사이트를 구축하려는 사람들에게 적합합니다. HTML, CSS, JavaScript를 사용하여 프런트엔드 개발 기술을 향상시키는 동시에 사용자를 위한 전문적인 웹 경험을 만들 수 있는 좋은 방법입니다.

프로젝트 개요

뉴스 홈페이지는 최신 뉴스 기사와 헤드라인을 정리된 레이아웃으로 표시하도록 설계된 웹 애플리케이션입니다. 현대적이고 반응성이 뛰어난 디자인을 통해 사용자는 최신 뉴스, 주요 기사 및 카테고리와 같은 다양한 섹션을 쉽게 탐색할 수 있습니다. 이 프로젝트는 유익하고 심미적으로 만족스러운 웹사이트를 만드는 방법을 보여줍니다.

특징

  • 반응형 레이아웃: 웹사이트는 다양한 화면 크기에 맞춰 조정되어 데스크톱과 모바일 기기 모두에서 최적의 보기 환경을 제공합니다.
  • 대화형 탐색: 사용자가 다양한 뉴스 카테고리를 원활하게 탐색할 수 있습니다.
  • 클린 디자인: 시각적으로 매력적이고 읽기 쉬운 형식으로 뉴스 기사를 제공합니다.

사용된 기술

  • HTML: 뉴스 홈페이지 웹사이트의 구조를 제공합니다.
  • CSS: 현대적이고 반응이 빠른 디자인을 만들기 위해 웹사이트 스타일을 지정합니다.
  • JavaScript: 동적 콘텐츠 로딩을 포함한 대화형 요소를 관리합니다.

프로젝트 구조

프로젝트 구조 개요는 다음과 같습니다.

News-Homepage/
├── index.html
├── style.css
└── script.js
  • index.html: 뉴스 홈페이지 웹사이트의 HTML 구조를 포함합니다.
  • style.css: CSS 스타일을 포함하여 매력적이고 반응이 빠른 디자인을 만듭니다.
  • script.js: 동적 콘텐츠 로딩과 같은 웹사이트의 대화형 요소를 관리합니다.

설치

프로젝트를 시작하려면 다음 단계를 따르세요.

  1. 저장소 복제:

    git clone https://github.com/abhishekgurjar-in/News-Homepage.git
    
  2. 프로젝트 디렉토리 열기:

    cd News-Homepage
    
  3. 프로젝트 실행:

    • 웹 브라우저에서 index.html 파일을 열어 뉴스 홈페이지를 확인하세요.

용법

  1. 웹사이트를 엽니다 웹 브라우저에서
  2. 섹션을 탐색상위 메뉴를 사용하여 다양한 뉴스 카테고리를 탐색하세요.
  3. 최신 기사와 주요 뉴스 기사를 읽어보세요.
  4. 제목을 클릭하여 자세한 뉴스 기사를 확인하세요.

코드 설명

HTML

index.html 파일은 다양한 뉴스 카테고리 및 바닥글에 대한 섹션을 포함하여 뉴스 홈페이지 웹사이트의 구조를 정의합니다. 다음은 일부 내용입니다.


  
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>News Homepage</title>
    <link href="https://fonts.googleapis.com/css?family=Inter:100,200,300,regular,500,600,700,800,900" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
    <script src="script.js" defer></script>
  
  
    <div class="container">
      <nav class="navigation">
        <div class="logo">
          <img src="./assets/images/logo.svg" alt="뉴스 웹사이트 홈페이지 구축">
        </div>
        <div class="menu-icon" onclick="toggleMenu()">
          <img src="./assets/images/icon-menu.svg" alt="Menu Icon">
        </div>
        <div class="heading">
          <a href="/">Home</a>
          <a href="/">New</a>
          <a href="/">Popular</a>
          <a href="/">Trending</a>
          <a href="/">Categories</a>
        </div>
      </nav>
      <div id="mobile-menu" class="mobile-menu">
        <a href="/">Home</a>
        <a href="/">New</a>
        <a href="/">Popular</a>
        <a href="/">Trending</a>
        <a href="/">Categories</a>
      </div>
      <main>
        <div class="left-main">
          <img src="./assets/images/image-web-3-desktop.jpg" alt="Web 3.0">
          <div class="body-text">
            <h1>The Bright <br>Future of <br>Web 3.0?</h1>
            <p>
              We dive into the next evolution of the web that claims to put the
              power of the platforms back into the hands of the people. But is
              it really fulfilling its promise?
              <br><br>
              <span>Read more</span>
            </p>
          </div>
        </div>
        <div class="right-main">
          <h1> New</h1>
          <div class="section">
            <h3>Hydrogen VS Electric Cars</h3>
            <p>Will hydrogen-fueled cars ever catch up to EVs?</p>
            <hr>
          </div>
          <div class="section">
            <h3>The Downsides of AI Artistry</h3>
            <p>
              What are the possible adverse effects of on-demand AI image
              generation?
            </p>
            <hr>
          </div>
          <div class="section">
            <h3>Is VC Funding Drying Up?</h3>
            <p>
              Private funding by VC firms is down 50% YOY. We take a look at
              what that means.
            </p>
            <hr>
          </div>
        </div>
      </main>
      <footer>
        <div class="card">
          <div class="card-image">
            <img src="./assets/images/image-retro-pcs.jpg" alt="Retro PCs">
          </div>
          <div class="card-text">
            <h1>01</h1>
            <h3>Reviving Retro PCs</h3>
            <p>What happens when old PCs are given modern upgrades?</p>
          </div>
        </div>
        <div class="card">
          <div class="card-image">
            <img src="./assets/images/image-top-laptops.jpg" alt="Top Laptops">
          </div>
          <div class="card-text">
            <h1>02</h1>
            <h3>Top 10 Laptops of 2022</h3>
            <p>Our best picks for various needs and budgets.</p>
          </div>
        </div>
        <div class="card">
          <div class="card-image">
            <img src="./assets/images/image-top-laptops.jpg" alt="Growth of Gaming">
          </div>
          <div class="card-text">
            <h1>03</h1>
            <h3>The Growth of Gaming</h3>
            <p>How the pandemic has sparked fresh opportunities.</p>
          </div>
        </div>
      </footer>
    </div>
    <div class="footer">
      <p>Made with ❤️ by Abhishek Gurjar</p>
    </div>
  


CSS

style.css 파일은 뉴스 홈페이지 웹사이트의 스타일을 지정하여 시각적으로 매력적이고 반응성이 뛰어납니다. 다음은 몇 가지 주요 스타일입니다.

* {
  box-sizing: border-box;
}

body {
  background-color: white;
  font-size: 16px;
  margin: 20px;
  font-family: Inter, sans-serif;
}

.container {
  max-width: 1100px;
  margin: auto;
}

.navigation {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 20px;
  margin: auto;
}

.logo img {
  width: 50px;
}

.heading a {
  cursor: pointer;
  padding-left: 20px;
  text-decoration: none;
  color: gray;
  display: inline-block;
}

.heading a:hover {
  color: rgb(253, 81, 81);
}

.menu-icon {
  display: none;
  cursor: pointer;
}

.menu-icon img {
  width: 30px;
}

.active {
  display: none;
}

.mobile-menu {
  display: none;
  flex-direction: column;
  align-items: center;
  background-color: white;
  padding: 10px;
}

.mobile-menu a {
  text-decoration: none;
  color: gray;
  padding: 10px;
  display: block;
}

.mobile-menu a:hover {
  color: rgb(253, 81, 81);
}

main {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.left-main {
  width: 80%;
  padding-right: 10px;
}

.left-main img {
  width: 100%;
}

.body-text {
  display: flex;
}

.body-text h1 {
  font-size: 40px;
  width: 50%;
}

.body-text p {
  font-size: 16px;
  width: 50%;
}

.body-text span {
  background-color: rgb(253, 81, 81);
  padding: 10px;
  cursor: pointer;
}

.body-text span:hover {
  background-color: black;
  color: white;
}

.right-main {
  padding: 10px;
  width: 40%;
  background-color: black;
}

.right-main h1 {
  color: rgb(237, 155, 15);
  font-size: 25px;
}

.right-main .section {
  margin: 10px;
}

.section h3 {
  cursor: pointer;
  color: white;
}

.section h3:hover {
  color: rgb(237, 155, 15);
}

.section p {
  color: gray;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card {
  gap: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-image img {
  width: 130px;
}

.card-text h1 {
  color: rgb(253, 81, 81);
}

.card-text h3:hover {
  color: rgb(253, 81, 81);
}

.footer {
  margin: 50px;
  text-align: center;
}

@media (max-width: 600px) {
  .heading {
    display: none;
  }

  .menu-icon {
    display: block;
  }

  main {
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  .body-text {
    flex-direction: column;
    align-items: center;
    padding: 20px;
  }

  footer {
    flex-direction: column;
  }
}

자바스크립트

script.js 파일에는 뉴스 홈페이지 웹사이트에 대한 모든 동적 기능이 포함되어 있습니다. 다음은 데모를 위한 간단한 스니펫입니다.

function toggleMenu() {
  const mobileMenu = document.getElementById("mobile-menu");
  const menuIcon = document.querySelector(".menu-icon img");

  if (mobileMenu.style.display === "flex") {
    mobileMenu.style.display = "none";
    menuIcon.src = "./assets/images/icon-menu.svg";
  } else {
    mobileMenu.style.display = "flex";
    menuIcon.src = "./assets/images/icon-menu-close.svg";
  }
}

라이브 데모

여기에서 뉴스 홈페이지 웹사이트 프로젝트의 라이브 데모를 확인하실 수 있습니다.

결론

뉴스 홈페이지 웹사이트 구축은 뉴스 기사를 제공하기 위한 깔끔하고 체계적인 웹 플랫폼을 만드는 데 있어 좋은 경험이었습니다. 이 프로젝트는 현대 웹 개발에서 반응형 디자인과 사용자 친화적인 탐색의 중요성을 강조합니다. HTML, CSS, JavaScript를 적용하여 사용자에게 귀중한 리소스 역할을 하는 전문적인 뉴스 웹사이트를 개발했습니다. 이 프로젝트가 여러분이 자신만의 뉴스나 콘텐츠 중심 웹사이트를 구축하는 데 영감을 주기를 바랍니다. 즐거운 코딩하세요!

크레딧

이 프로젝트는 웹 개발에 대한 지속적인 학습 여정의 일환으로 개발되었습니다.

작가

  • 아비셰크 구자르
    • GitHub 프로필

위 내용은 뉴스 웹사이트 홈페이지 구축의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.