Я разрабатываю веб-страницу, но на странице присутствует горизонтальная полоса прокрутки. Я хочу удалить его, но не могу. Недавно я занялся веб-разработкой, и большинство веб-страниц, которые я делал для практики, столкнулись с одной и той же проблемой.
Я ожидаю, что следующая часть кода будет ошибочной
.heading::before{border: 2px solid chocolate;
content: "";
height: 100vh;
background: url(....) no-repeat center ;
width: 100vw;
position: absolute;
top: 0px;
left: 0px;
z-index: -1; }
*{
margin: 0px;
padding: 0px;
}
nav{
position: sticky;
top: 0px;
left:0px;
margin: 0px 0px 10px 0px;
padding: 5px 5px;
background-color: #15191f;
}
.heading{
height: 90vh;
}
.heading::before{
border: 2px solid chocolate;
content: "";
height: 100vh;
background: url() no-repeat center ;
width: 100vw;
position: absolute;
top: 0px;
left: 0px;
z-index: -1;
}
.flex{
display: flex;
}
.flex-row{
flex-direction: row;
}
.flex-column{
flex-direction: column;
}
.wrap{
flex-wrap: wrap;
}
.al-cen{
align-items: center;
}
.ju-cen{
justify-content: center;
}
nav a{
text-decoration: none;
background-color: #15191f;
color: #e3ecf3;
padding: 4px 10px;
border: 2px;
border-radius: 10px;
}
nav a:hover{
color: #15191f;
background-color: #e3ecf3;
}
#li1{
margin-left: 50px;
}
#a1{
margin: 0px 4px;
}
#a2{
margin: 0px 4px;
}
#a3{
margin: 0px 4px;
}
#a4{
margin: 0px 4px;
}
nav ul li{
list-style: none;
}
#logo{
width: 5vw;
border: 2px ;
border-radius:100mm;
}
/* -------------------------------------------------------------------- */
div ul{
margin: 0px 40px;
}
body{
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size: 1.5vw;
background-color: #e3ecf3;
}
div{
margin: 20px 15px;
}
ol li{
margin: 0px 40px;
}
.block{
display:block;
}
.inline-block{
display: inline-block;
}
.border-red{
border: 3.5px solid red;
border-radius: 12px;
}
.border-green{
border: 3.5px solid green;
border-radius: 5px;
}
.border-blue{
border: 3.5px solid blue;
border-radius: 5px;
}
.line-height{
line-height: 8vh;
}
ol{
border: 2px solid blue;
border-radius: 5px;
text-align: center;
/* display: inline-block; */
margin: 4px 0px;
width:300px
}
.text-cen{
text-align: center;
}
ol li{
margin-left: 40px;
}
input{
display: block;
}
option{
background-color:#15191f;
color:#e3ecf3;
height: 50px;
font-size: 1.1rem;
border-radius: 5px;
}
select{
width: 85px;
background-color:#15191f;
color:#e3ecf3;
height:30px;
border: 2px solid #15191f;
border-radius: 6px;
}
.button{
height: 25px;
width: 25px;
/* border: 2px solid #15191f; */
border-radius: 100px;
/* background-color: #15191f; */
}
/* .button: */
.checkbox{
/* background-color: #15191f; */
height: 25px;
width: 25px;
}
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<meta http-equiv = "X-UA-Compatible" content = "IE=edge">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<title>All in One</title>
<link rel = "stylesheet" href = "../CSS/home.css">
<script src = "../JS/home.js"></script>
</head>
<body class = "">
<nav class = "flex row al-cen">
<img id = "logo" src = "../random_source" alt = "Error loading image">
<ul class = "flex row">
<li id = "li1"><a id = "a1" href = "../HTML/home.html" target = "_blank">Home</a></li>
<li id = "li2"><a id = "a2" href = "../HTML/about.html" target = "_blank">About Us</a></li>
<li id = "li3"><a id = "a3" href = "../HTML/services.html" target = "_blank">Our Services</a></li>
<li id = "li4"><a id = "a4" href = "../HTML/contact.html" target = "_blank">Contact Us</a></li>
</ul>
</nav>
<div class = "heading flex flex-column al-cen ju-cen">
<h1 class = "line-height">All in ONE Website</h1>
<p>This <strong>Website</strong> aims to <i>include</i> all that has been <em>learnt</em> and keep a record of
it for future usage.</p>
</div>
<hr>
<div class = "border-red firstpara">
<p><b>
<\b>This Bold<\b>
</b>Lorem ipsum dolor sit amet consectetur, adipisicing elit. <br><strong>
<\br> Has been used here and here<\br><br>
</strong> modi molestias omnis voluptate alias unde voluptates provident hic voluptatibus ipsum deleniti
itaque
delectus et expedita quisquam, non soluta, harum consequuntur sapiente rem quaerat. Repellendus, impedit.
</p>
</div>
<div class = "border-green lists">
<div class = "orderdlist block border flex-row ">
<ol id = "ol1" class = "inline-block" type = "1">
<h6>OL type 1</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "olA" class = "inline-block" type = "A">
<h6>OL type A</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "ola" class = "inline-block" type = "a">
<h6>OL type a</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "olI" class = "inline-block" type = "I">
<h6>OL type I</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "oli" class = "inline-block" type = "i">
<h6>OL type i</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
</div>
<div class = "unorderedlist">
<ul type = "square">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
<ul type = "circle">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
<ul type = "disc">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
</div>
</div>
<div class = "border-blue table text-cen flex flex-column wrap">
<h3>This is a Table</h3>
<table>
<thead>
<tr>
<th>Heading-1</th>
<th>Heading-2</th>
<th>Heading-3</th>
<th>Heading-4</th>
<th>Heading-5</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row-1-Colum-1</td>
<td>Row-1-Colum-2</td>
<td>Row-1-Colum-3</td>
<td>Row-1-Colum-4</td>
<td>Row-1-Colum-5</td>
</tr>
<tr>
<td>Row-2-Column-1</td>
<td>Row-2-Column-2</td>
<td>Row-2-Column-3</td>
<td>Row-2-Column-4</td>
<td>Row-2-Column-5</td>
</tr>
<tr>
<td>Row-3-Column-1</td>
<td>Row-3-Column-2</td>
<td>Row-3-Column-3</td>
<td>Row-3-Column-4</td>
<td>Row-3-Column-5</td>
</tr>
</tbody>
</table>
</div>
<div class = "border-red forms flex flex-column">
<h1 class = "text-cen">FORMS</h1>
<h5>Below are some types of input we can ask on forms.Include a NAME in input tags
</h5>
<p>We will make input tag a block element to make go to next line and make the code look clean.
Before it was inline so elements crammmed over each other.We can add value = "" to show that thing.<br>
The diff between value and placeholder is that the placeholder gets removed whan an item is entered, wheras
when we enter an item at place of value, it concencates in the value. Placeholder is Background, value is
not.
@gmail.com is value below in email. Remaining are Placeholder
</p>
<form action = "#">
Button <input class = "button" type = "button" placeholder = "Placeholder">
Checkbox<input type = "checkbox" class = "checkbox" placeholder = "Placeholder">
Color<input type = "color" placeholder = "Placeholder">
Date<input type = "date" placeholder = "Placeholder">
Datetime<input type = "datetime" placeholder = "Placeholder">
Datetime-local<input type = "datetime-local" placeholder = "Placeholder"><p>Just Testing</p>
Email<input type = "email" value = "@gmail.com" placeholder = "Placeholder">
File<input type = "file" placeholder = "Placeholder">
Hidden<input type = "hidden" placeholder = "Placeholder">
Image<input type = "image" placeholder = "Placeholder">
Month<input type = "month" placeholder = "Placeholder">
Number<input type = "number" placeholder = "Placeholder">
Password<input type = "password" placeholder = "Placeholder">
Radio<input type = "radio" placeholder = "Placeholder">
Range<input type = "range" placeholder = "Placeholder">
Reset<input type = "reset" placeholder = "Placeholder">
Search<input type = "search" placeholder = "Placeholder">
Submit<input type = "submit" placeholder = "Placeholder">
Tel<input type = "tel" placeholder = "Placeholder">
Text<input type = "text" placeholder = "Placeholder">
Time<input type = "time" placeholder = "Placeholder">
Url<input type = "url" placeholder = "Placeholder">
Week<input type = "week" placeholder = "Placeholder">
Select from a dropdown <select>
<option value = "Option-1-Val">Option-1</option>
<option value = "Option-2-Val">Option-2</option>
<option value = "Option-3-Val">Option-3</option>
<option value = "Option-4-Val">Option-4</option>
<option value = "Option-5-Val">Option-5</option>
</select>
</form>
</div>
<div class = "entities border-green">
<h4>We use entities for displaying some character</h4>
<
<!-- Less Than -->
>
<!-- Greater Than -->
£
<!-- pound -->
©
<!-- copy -->
⇛
<!-- Arrow -->
½
<!-- In form of fraction -->
</div>
<div class = "border-blue semanticelements">
<p>A dropdown button which shows whatever is written in summary and when clicked reveals what is written in detail tag.</p>
<details>
<summary>I have keys but no doors. I have space but no room. You can enter but you can't leave. What am i?</summary>
A Keyboard.
</details>
<p>Now i will use a time tag</p>
<p>We will be celebrating new year on <time datetime = "2022-12-12">December 12</time> in my house.</p>
</div>
</body>
</html>
В частности width: 100vw
, если я удалю эту строку, полоса прокрутки исчезнет, но исчезнет и изображение.
width:auto
также заставляет изображение исчезать.
Если возможно, предложите другие способы, которые позволят мне отображать изображение на весь экран, не вызывая эстетических проблем. Изображение должно быть в фоновом режиме и только для определенного тега, а не для всей веб-страницы.
Граница добавляет дополнительную ширину, как вы заметили. Вы пытались установить box-sizing: border-box?
@ZachJensz Готовый фрагмент
@AHaworth В качестве быстрой проверки того, что вы упомянули, я написал *{box-sizing:borderbox} в css. Это ничего не меняет
Что случилось с дефисом?
Я удалил ссылку на изображение из кода, но проблема все еще сохраняется. Может быть ясно по показанной границе.
@AHaworth Все еще ничего. *{поле: 0px; отступ: 0px; box-sizing: граница-коробка; }
Вам нужно установить box-sizing специально для псевдоэлементов.
*, *::before, *::after{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
nav{
position: sticky;
top: 0px;
left:0px;
margin: 0px 0px 10px 0px;
padding: 5px 5px;
background-color: #15191f;
}
.heading{
height: 90vh;
}
.heading::before{
border: 2px solid chocolate;
content: "";
height: 100vh;
background: url() no-repeat center ;
width: 100vw;
position: absolute;
top: 0px;
left: 0px;
z-index: -1;
}
.flex{
display: flex;
}
.flex-row{
flex-direction: row;
}
.flex-column{
flex-direction: column;
}
.wrap{
flex-wrap: wrap;
}
.al-cen{
align-items: center;
}
.ju-cen{
justify-content: center;
}
nav a{
text-decoration: none;
background-color: #15191f;
color: #e3ecf3;
padding: 4px 10px;
border: 2px;
border-radius: 10px;
}
nav a:hover{
color: #15191f;
background-color: #e3ecf3;
}
#li1{
margin-left: 50px;
}
#a1{
margin: 0px 4px;
}
#a2{
margin: 0px 4px;
}
#a3{
margin: 0px 4px;
}
#a4{
margin: 0px 4px;
}
nav ul li{
list-style: none;
}
#logo{
width: 5vw;
border: 2px ;
border-radius:100mm;
}
/* -------------------------------------------------------------------- */
div ul{
margin: 0px 40px;
}
body{
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size: 1.5vw;
background-color: #e3ecf3;
}
div{
margin: 20px 15px;
}
ol li{
margin: 0px 40px;
}
.block{
display:block;
}
.inline-block{
display: inline-block;
}
.border-red{
border: 3.5px solid red;
border-radius: 12px;
}
.border-green{
border: 3.5px solid green;
border-radius: 5px;
}
.border-blue{
border: 3.5px solid blue;
border-radius: 5px;
}
.line-height{
line-height: 8vh;
}
ol{
border: 2px solid blue;
border-radius: 5px;
text-align: center;
/* display: inline-block; */
margin: 4px 0px;
width:300px
}
.text-cen{
text-align: center;
}
ol li{
margin-left: 40px;
}
input{
display: block;
}
option{
background-color:#15191f;
color:#e3ecf3;
height: 50px;
font-size: 1.1rem;
border-radius: 5px;
}
select{
width: 85px;
background-color:#15191f;
color:#e3ecf3;
height:30px;
border: 2px solid #15191f;
border-radius: 6px;
}
.button{
height: 25px;
width: 25px;
/* border: 2px solid #15191f; */
border-radius: 100px;
/* background-color: #15191f; */
}
/* .button: */
.checkbox{
/* background-color: #15191f; */
height: 25px;
width: 25px;
}
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<meta http-equiv = "X-UA-Compatible" content = "IE=edge">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<title>All in One</title>
<link rel = "stylesheet" href = "../CSS/home.css">
<script src = "../JS/home.js"></script>
</head>
<body class = "">
<nav class = "flex row al-cen">
<img id = "logo" src = "../random_source" alt = "Error loading image">
<ul class = "flex row">
<li id = "li1"><a id = "a1" href = "../HTML/home.html" target = "_blank">Home</a></li>
<li id = "li2"><a id = "a2" href = "../HTML/about.html" target = "_blank">About Us</a></li>
<li id = "li3"><a id = "a3" href = "../HTML/services.html" target = "_blank">Our Services</a></li>
<li id = "li4"><a id = "a4" href = "../HTML/contact.html" target = "_blank">Contact Us</a></li>
</ul>
</nav>
<div class = "heading flex flex-column al-cen ju-cen">
<h1 class = "line-height">All in ONE Website</h1>
<p>This <strong>Website</strong> aims to <i>include</i> all that has been <em>learnt</em> and keep a record of
it for future usage.</p>
</div>
<hr>
<div class = "border-red firstpara">
<p><b>
<\b>This Bold<\b>
</b>Lorem ipsum dolor sit amet consectetur, adipisicing elit. <br><strong>
<\br> Has been used here and here<\br><br>
</strong> modi molestias omnis voluptate alias unde voluptates provident hic voluptatibus ipsum deleniti
itaque
delectus et expedita quisquam, non soluta, harum consequuntur sapiente rem quaerat. Repellendus, impedit.
</p>
</div>
<div class = "border-green lists">
<div class = "orderdlist block border flex-row ">
<ol id = "ol1" class = "inline-block" type = "1">
<h6>OL type 1</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "olA" class = "inline-block" type = "A">
<h6>OL type A</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "ola" class = "inline-block" type = "a">
<h6>OL type a</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "olI" class = "inline-block" type = "I">
<h6>OL type I</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "oli" class = "inline-block" type = "i">
<h6>OL type i</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
</div>
<div class = "unorderedlist">
<ul type = "square">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
<ul type = "circle">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
<ul type = "disc">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
</div>
</div>
<div class = "border-blue table text-cen flex flex-column wrap">
<h3>This is a Table</h3>
<table>
<thead>
<tr>
<th>Heading-1</th>
<th>Heading-2</th>
<th>Heading-3</th>
<th>Heading-4</th>
<th>Heading-5</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row-1-Colum-1</td>
<td>Row-1-Colum-2</td>
<td>Row-1-Colum-3</td>
<td>Row-1-Colum-4</td>
<td>Row-1-Colum-5</td>
</tr>
<tr>
<td>Row-2-Column-1</td>
<td>Row-2-Column-2</td>
<td>Row-2-Column-3</td>
<td>Row-2-Column-4</td>
<td>Row-2-Column-5</td>
</tr>
<tr>
<td>Row-3-Column-1</td>
<td>Row-3-Column-2</td>
<td>Row-3-Column-3</td>
<td>Row-3-Column-4</td>
<td>Row-3-Column-5</td>
</tr>
</tbody>
</table>
</div>
<div class = "border-red forms flex flex-column">
<h1 class = "text-cen">FORMS</h1>
<h5>Below are some types of input we can ask on forms.Include a NAME in input tags
</h5>
<p>We will make input tag a block element to make go to next line and make the code look clean.
Before it was inline so elements crammmed over each other.We can add value = "" to show that thing.<br>
The diff between value and placeholder is that the placeholder gets removed whan an item is entered, wheras
when we enter an item at place of value, it concencates in the value. Placeholder is Background, value is
not.
@gmail.com is value below in email. Remaining are Placeholder
</p>
<form action = "#">
Button <input class = "button" type = "button" placeholder = "Placeholder">
Checkbox<input type = "checkbox" class = "checkbox" placeholder = "Placeholder">
Color<input type = "color" placeholder = "Placeholder">
Date<input type = "date" placeholder = "Placeholder">
Datetime<input type = "datetime" placeholder = "Placeholder">
Datetime-local<input type = "datetime-local" placeholder = "Placeholder"><p>Just Testing</p>
Email<input type = "email" value = "@gmail.com" placeholder = "Placeholder">
File<input type = "file" placeholder = "Placeholder">
Hidden<input type = "hidden" placeholder = "Placeholder">
Image<input type = "image" placeholder = "Placeholder">
Month<input type = "month" placeholder = "Placeholder">
Number<input type = "number" placeholder = "Placeholder">
Password<input type = "password" placeholder = "Placeholder">
Radio<input type = "radio" placeholder = "Placeholder">
Range<input type = "range" placeholder = "Placeholder">
Reset<input type = "reset" placeholder = "Placeholder">
Search<input type = "search" placeholder = "Placeholder">
Submit<input type = "submit" placeholder = "Placeholder">
Tel<input type = "tel" placeholder = "Placeholder">
Text<input type = "text" placeholder = "Placeholder">
Time<input type = "time" placeholder = "Placeholder">
Url<input type = "url" placeholder = "Placeholder">
Week<input type = "week" placeholder = "Placeholder">
Select from a dropdown <select>
<option value = "Option-1-Val">Option-1</option>
<option value = "Option-2-Val">Option-2</option>
<option value = "Option-3-Val">Option-3</option>
<option value = "Option-4-Val">Option-4</option>
<option value = "Option-5-Val">Option-5</option>
</select>
</form>
</div>
<div class = "entities border-green">
<h4>We use entities for displaying some character</h4>
<
<!-- Less Than -->
>
<!-- Greater Than -->
£
<!-- pound -->
©
<!-- copy -->
⇛
<!-- Arrow -->
½
<!-- In form of fraction -->
</div>
<div class = "border-blue semanticelements">
<p>A dropdown button which shows whatever is written in summary and when clicked reveals what is written in detail tag.</p>
<details>
<summary>I have keys but no doors. I have space but no room. You can enter but you can't leave. What am i?</summary>
A Keyboard.
</details>
<p>Now i will use a time tag</p>
<p>We will be celebrating new year on <time datetime = "2022-12-12">December 12</time> in my house.</p>
</div>
</body>
</html>
у меня боковая прокрутка
Какой у вас браузер и ОС? В данный момент я ограничен iPad, использую Safari и вижу полную красную рамку, а боковая (горизонтальная) прокрутка отсутствует. Я предполагаю, что вы находитесь на чем-то, что показывает вертикальную полосу прокрутки и занимает часть ширины.
Горизонтальная полоса прокрутки осталась.
На пк вин 10 браузер опера
Вам нужно учесть ширину вертикальной полосы прокрутки.
Да, это, вероятно, полоса прокрутки. Я использую Firefox Linux Desktop
Рад узнать, что он не отображается в Safari.
К псевдоэлементу я добавил box-sizing: border-box
и изменил ширину на 100%
вместо 100vw
.
box-sizing: border-box
Это изменяет поле, используемое при объявлении абсолютной ширины. Когда мы устанавливаем для него значение border-box, это означает, что граница размещается внутри объявленной ширины, а не добавляется к ней. у меня есть поле шириной 100 пикселей с границей 2 пикселя, я хочу, чтобы граница была включена в эти 100 пикселей, а не добавлялась к ней.
width: 100%
Ширина в процентах относится к ширине контейнера, тогда как область просмотра относится к области просмотра. 100% означает, что я занимаю всю ширину контейнера, в котором я нахожусь, 100vw означает, что он занимает всю ширину области просмотра (включая полосу прокрутки).
* {
margin: 0px;
padding: 0px;
}
nav {
position: sticky;
top: 0px;
left: 0px;
margin: 0px 0px 10px 0px;
padding: 5px 5px;
background-color: #15191f;
}
.heading {
height: 90vh;
}
.heading::before {
box-sizing: border-box;
border: 2px solid chocolate;
content: "";
height: 100vh;
background: url() no-repeat center;
width: 100%;
position: absolute;
top: 0px;
left: 0px;
z-index: -1;
}
.flex {
display: flex;
}
.flex-row {
flex-direction: row;
}
.flex-column {
flex-direction: column;
}
.wrap {
flex-wrap: wrap;
}
.al-cen {
align-items: center;
}
.ju-cen {
justify-content: center;
}
nav a {
text-decoration: none;
background-color: #15191f;
color: #e3ecf3;
padding: 4px 10px;
border: 2px;
border-radius: 10px;
}
nav a:hover {
color: #15191f;
background-color: #e3ecf3;
}
#li1 {
margin-left: 50px;
}
#a1 {
margin: 0px 4px;
}
#a2 {
margin: 0px 4px;
}
#a3 {
margin: 0px 4px;
}
#a4 {
margin: 0px 4px;
}
nav ul li {
list-style: none;
}
#logo {
width: 5vw;
border: 2px;
border-radius: 100mm;
}
/* -------------------------------------------------------------------- */
div ul {
margin: 0px 40px;
}
body {
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 1.5vw;
background-color: #e3ecf3;
}
div {
margin: 20px 15px;
}
ol li {
margin: 0px 40px;
}
.block {
display: block;
}
.inline-block {
display: inline-block;
}
.border-red {
border: 3.5px solid red;
border-radius: 12px;
}
.border-green {
border: 3.5px solid green;
border-radius: 5px;
}
.border-blue {
border: 3.5px solid blue;
border-radius: 5px;
}
.line-height {
line-height: 8vh;
}
ol {
border: 2px solid blue;
border-radius: 5px;
text-align: center;
/* display: inline-block; */
margin: 4px 0px;
width: 300px
}
.text-cen {
text-align: center;
}
ol li {
margin-left: 40px;
}
input {
display: block;
}
option {
background-color: #15191f;
color: #e3ecf3;
height: 50px;
font-size: 1.1rem;
border-radius: 5px;
}
select {
width: 85px;
background-color: #15191f;
color: #e3ecf3;
height: 30px;
border: 2px solid #15191f;
border-radius: 6px;
}
.button {
height: 25px;
width: 25px;
/* border: 2px solid #15191f; */
border-radius: 100px;
/* background-color: #15191f; */
}
/* .button: */
.checkbox {
/* background-color: #15191f; */
height: 25px;
width: 25px;
}
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<meta http-equiv = "X-UA-Compatible" content = "IE=edge">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
<title>All in One</title>
<link rel = "stylesheet" href = "../CSS/home.css">
<script src = "../JS/home.js"></script>
</head>
<body class = "">
<nav class = "flex row al-cen">
<img id = "logo" src = "../random_source" alt = "Error loading image">
<ul class = "flex row">
<li id = "li1"><a id = "a1" href = "../HTML/home.html" target = "_blank">Home</a></li>
<li id = "li2"><a id = "a2" href = "../HTML/about.html" target = "_blank">About Us</a></li>
<li id = "li3"><a id = "a3" href = "../HTML/services.html" target = "_blank">Our Services</a></li>
<li id = "li4"><a id = "a4" href = "../HTML/contact.html" target = "_blank">Contact Us</a></li>
</ul>
</nav>
<div class = "heading flex flex-column al-cen ju-cen">
<h1 class = "line-height">All in ONE Website</h1>
<p>This <strong>Website</strong> aims to <i>include</i> all that has been <em>learnt</em> and keep a record of it for future usage.</p>
</div>
<hr>
<div class = "border-red firstpara">
<p><b>
<\b>This Bold<\b>
</b>Lorem ipsum dolor sit amet consectetur, adipisicing elit. <br><strong>
<\br> Has been used here and here<\br><br>
</strong> modi molestias omnis voluptate alias unde voluptates provident hic voluptatibus ipsum deleniti itaque delectus et expedita quisquam, non soluta, harum consequuntur sapiente rem quaerat. Repellendus, impedit.
</p>
</div>
<div class = "border-green lists">
<div class = "orderdlist block border flex-row ">
<ol id = "ol1" class = "inline-block" type = "1">
<h6>OL type 1</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "olA" class = "inline-block" type = "A">
<h6>OL type A</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "ola" class = "inline-block" type = "a">
<h6>OL type a</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "olI" class = "inline-block" type = "I">
<h6>OL type I</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
<ol id = "oli" class = "inline-block" type = "i">
<h6>OL type i</h6>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ol>
</div>
<div class = "unorderedlist">
<ul type = "square">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
<ul type = "circle">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
<ul type = "disc">
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
<li>Lorem ipsum dolor sit amet.</li>
</ul>
</div>
</div>
<div class = "border-blue table text-cen flex flex-column wrap">
<h3>This is a Table</h3>
<table>
<thead>
<tr>
<th>Heading-1</th>
<th>Heading-2</th>
<th>Heading-3</th>
<th>Heading-4</th>
<th>Heading-5</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row-1-Colum-1</td>
<td>Row-1-Colum-2</td>
<td>Row-1-Colum-3</td>
<td>Row-1-Colum-4</td>
<td>Row-1-Colum-5</td>
</tr>
<tr>
<td>Row-2-Column-1</td>
<td>Row-2-Column-2</td>
<td>Row-2-Column-3</td>
<td>Row-2-Column-4</td>
<td>Row-2-Column-5</td>
</tr>
<tr>
<td>Row-3-Column-1</td>
<td>Row-3-Column-2</td>
<td>Row-3-Column-3</td>
<td>Row-3-Column-4</td>
<td>Row-3-Column-5</td>
</tr>
</tbody>
</table>
</div>
<div class = "border-red forms flex flex-column">
<h1 class = "text-cen">FORMS</h1>
<h5>Below are some types of input we can ask on forms.Include a NAME in input tags
</h5>
<p>We will make input tag a block element to make go to next line and make the code look clean. Before it was inline so elements crammmed over each other.We can add value = "" to show that thing.<br> The diff between value and placeholder is that the placeholder
gets removed whan an item is entered, wheras when we enter an item at place of value, it concencates in the value. Placeholder is Background, value is not. @gmail.com is value below in email. Remaining are Placeholder
</p>
<form action = "#">
Button <input class = "button" type = "button" placeholder = "Placeholder"> Checkbox
<input type = "checkbox" class = "checkbox" placeholder = "Placeholder"> Color
<input type = "color" placeholder = "Placeholder"> Date
<input type = "date" placeholder = "Placeholder"> Datetime
<input type = "datetime" placeholder = "Placeholder"> Datetime-local
<input type = "datetime-local" placeholder = "Placeholder">
<p>Just Testing</p>
Email<input type = "email" value = "@gmail.com" placeholder = "Placeholder"> File
<input type = "file" placeholder = "Placeholder"> Hidden
<input type = "hidden" placeholder = "Placeholder"> Image
<input type = "image" placeholder = "Placeholder"> Month
<input type = "month" placeholder = "Placeholder"> Number
<input type = "number" placeholder = "Placeholder"> Password
<input type = "password" placeholder = "Placeholder"> Radio
<input type = "radio" placeholder = "Placeholder"> Range
<input type = "range" placeholder = "Placeholder"> Reset
<input type = "reset" placeholder = "Placeholder"> Search
<input type = "search" placeholder = "Placeholder"> Submit
<input type = "submit" placeholder = "Placeholder"> Tel
<input type = "tel" placeholder = "Placeholder"> Text
<input type = "text" placeholder = "Placeholder"> Time
<input type = "time" placeholder = "Placeholder"> Url
<input type = "url" placeholder = "Placeholder"> Week
<input type = "week" placeholder = "Placeholder"> Select from a dropdown
<select>
<option value = "Option-1-Val">Option-1</option>
<option value = "Option-2-Val">Option-2</option>
<option value = "Option-3-Val">Option-3</option>
<option value = "Option-4-Val">Option-4</option>
<option value = "Option-5-Val">Option-5</option>
</select>
</form>
</div>
<div class = "entities border-green">
<h4>We use entities for displaying some character</h4>
<
<!-- Less Than -->
>
<!-- Greater Than -->
£
<!-- pound -->
©
<!-- copy -->
⇛
<!-- Arrow -->
½
<!-- In form of fraction -->
</div>
<div class = "border-blue semanticelements">
<p>A dropdown button which shows whatever is written in summary and when clicked reveals what is written in detail tag.</p>
<details>
<summary>I have keys but no doors. I have space but no room. You can enter but you can't leave. What am i?</summary>
A Keyboard.
</details>
<p>Now i will use a time tag</p>
<p>We will be celebrating new year on <time datetime = "2022-12-12">December 12</time> in my house.</p>
</div>
</body>
</html>
Это РАБОТАЕТ, но прежде чем я отмечу этот ответ как правильный, можете ли вы объяснить, почему это работает, а не 100vw.
@BlaackWork Это работает, потому что ширина в процентах относится к ширине контейнера, тогда как область просмотра относится к области просмотра. 100% означает, что я занимаю всю ширину контейнера, в котором я нахожусь, 100vw означает, что он занимает всю ширину области просмотра (включая полосу прокрутки).
Я обновил вопрос с дополнительным объяснением
Любой другой способ сделать то же самое? Просто спрашиваю. Это здорово иметь резервную копию.
@BlaackWork, ха-ха, спасибо. Вы разблокируете эту функцию в ближайшее время. Не думайте, что есть другой способ определить ширину относительно родителя, для этого вам должно хватить процентов.
В основном теге вашего сайта вы должны указать ширину 100%:
width : 100%;
если вы установите 100vw, ваш браузер примет overflow-x, а также ширину вертикальной полосы прокрутки.
Это не решит проблему, так как граница по-прежнему будет вызывать переполнение элемента.
Сделайте исполняемый фрагмент со всем вашим кодом