使用 HTML 和 CSS 建立瀏覽器視窗
瀏覽器視窗是網頁瀏覽器圖形使用者介面 (GUI) 元素,用於顯示網頁和網路應用程式。它通常包括標題欄、選單欄、位址列、導航按鈕和內容區域。
演算法
建立一個帶有圓角、邊框和隱藏溢位的容器 div。
在容器內建立一個帶有背景顏色、填充和導航欄的標題。
應將指向各個頁面的連結新增到導航欄中。
在標題中新增搜尋按鈕和文字輸入欄位。
在主段落中,您可以包含標題。
容器的右上角應有 3 個按鈕,用於最小化、最大化和關閉。
使搜尋欄和按鈕位於標題的中心。
主段落應放在容器的中心。
將 CSS 樣式應用於每個元素,例如字型大小、顏色、邊距和填充。
示例
<!DOCTYPE html>
<html>
<head>
<title>Tutorialspoint</title>
<style>
/* CSS styles */
/* Style for the container */
.container {
width: 80%;
margin: 0 auto;
border: 1px solid #ccc;
border-radius: 5px;
overflow: hidden;
}
/* Style for the header */
header {
background-color: #f2f2f2;
padding: 10px;
display: flex;
justify-content: space-around;
flex-direction: column;
}
/* Style for the navigation bar */
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
}
/* Style for the navigation links */
nav a {
color: #333;
text-decoration: none;
font-weight: bold;
}
/* Style for the hover effect on navigation links */
nav a:hover {
text-decoration: underline;
}
/* Style for the buttons */
.buttons {
display: flex;
align-items: center;
}
/* Styling buttons */
.minimize, .maximize, .close {
height: 10px;
width: 10px;
margin-right: 5px;
border-radius: 50%;
}
/* Styling minimize button */
.minimize {
background-color: #ff9800;
color: #ff9800;
}
/* Maximize button */
.maximize {
background-color: #4caf50;
}
/* Close button colour */
.close {
background-color: #f44336;
}
/* Form styles */
form {
display: flex;
flex-direction: column;
align-items: center;
padding: 10px;
}
/* Styling the search input */
input[type="text"] {
padding: 10px;
border: none;
border-radius: 5px;
margin-right: 5px;
width: 50%;
}
/* search button styles */
button[type="submit"] {
padding: 10px;
border: none;
border-radius: 5px;
margin-right: 5px;
cursor: pointer;
background-color: #f2f2f2;
color: #333;
}
/* Hover effect on buttons */
button[type="submit"]:hover,
button:not([type="submit"]):hover {
background-color: #333;
color: #fff;
}
/* Padding the main content */
main {
padding: 10px;
}
h1 {
font-size: 36px;
color: #333;
margin-bottom: 10px;
}
/* Styling main paragraph */
p {
font-size: 18px;
color: #666;
}
</style>
</head>
<body>
<div class="container">
<div class="buttons">
<button class="minimize"></button> <!-- Minimize button -->
<button class="maximize"></button> <!-- Maximize button -->
<button class="close"></button> <!-- Close button -->
</div>
<header>
<nav>
<!-- Nav elements -->
<a href="#">Gmail</a>
<a href="#">Images</a>
<a href="#">Apps</a>
<a href="#">Notifications</a>
<a href="#">Account</a>
</nav>
<!-- Search Bar -->
<form>
<input type="text" placeholder="https://tutorialspoint.tw/">
<button type="submit">Search</button>
</form>
</header>
<main>
<!-- Heading -->
<h1>Welcome to Tutorialspoint</h1>
<!-- Paragraph -->
<p>Tutorialspoint is a free online learning platform where you can learn various programming and technology-related subjects. We aim to provide high-quality education to everyone, everywhere.</p>
</main>
</div>
</body>
</html>
結論
除了這種方法之外,我們還可以使用以下技術來實現。
我們可以使用 Bootstrap,這是一個流行的前端框架,它提供各種預製 UI 元件。可以使用 Bootstrap 模態元件建立瀏覽器視窗。您可以修改模態以滿足您的需求。
JavaScript 中的 window.open() 方法會開啟一個新的瀏覽器選項卡。還可以使用 window.location.href 屬性更改當前瀏覽器視窗的 URL。
為了構建瀏覽器視窗,各種 CSS 框架(如 Bulma、Tailwind 和 Foundation)提供了預製 UI 元件。
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP