У меня возникли проблемы с блоком display.block CSS, который я применяю к диапазону внутри элемента div, и он влияет на несколько элементов div и перемещает все вокруг него влево от всего контейнера. В моем коде цель состоит в том, чтобы адрес отображался в виде блока, но номер телефона и номер по-прежнему занимали всю горизонтальную ширину контейнера. Я смотрю видео о том, как это сделать, и человек, похоже, вообще не сталкивается с этой проблемой, и я не уверен, где я сделал ошибку. При запуске я прикрепил скриншот страницы, который показывает, как адрес смещается как блок, но также влияет на все, что рядом с ним, даже если у них разные классы, например c.
Вот изображение страницы, показывающее, что происходит
function initMap() {
var seattle = {
lat: 47.608013,
lng: -122.335167
};
const map = new google.maps.Map(document.getElementById('map'), {
center: seattle,
zoom: 11,
mapTypeId: 'roadmap',
});
}
body {
font-family: Arial, Helvetica, sans-serif;
height: 100vh;
margin: 0;
padding: 0;
}
#map {
width: 100%;
height: 100%;
}
.title {
position: absolute;
z-index: 100;
font-size: 50px;
font-weight: bold;
color: #333;
text-transform: uppercase;
top: 70px;
left: 25px;
border-radius: 25px;
border: 2px solid #333;
padding-left: 15px;
padding-right: 15px;
padding-top: 5px;
padding-bottom: 5px;
}
.search-container {
border-radius: 30px;
position: absolute;
z-index: 100;
top: 155px;
left: 25px;
width: 400px;
height: 60px;
background-color: #454E53;
display: flex;
}
.search-container .search {
flex-grow: 1;
display: flex;
align-items: center;
padding-left: 20px;
padding-right: 20px;
}
.search-container input {
width: 100%;
font-size: 25px;
background-color: transparent;
border: none;
color: white;
}
.search-container input:focus {
outline: none;
}
.search i {
font-size: 25px;
color: white;
}
.stores-list-container {
width: 360px;
position: absolute;
z-index: 100;
background: white;
left: 25px;
top: 228px;
border-radius: 30px;
bottom: 20px;
display: flex;
overflow-y: hidden;
padding-bottom: 30px;
padding-left: 20px;
padding-right: 10px;
}
.store-address {
font-size: 18px;
color: #514C4D;
margin-top: 30px;
}
.store-address span {
display: block;
}
.store-phone-number {
color: #B5ADAD;
margin-top: 15px;
margin-bottom: 15px;
}
<!DOCTYPE html>
<html>
<head>
<title>John's Google Map Project</title>
<script src="js/store-data.js"></script>
<script src="js/index.js"></script>
<link rel="stylesheet" href="style/style.css">
<script src="https://kit.fontawesome.com/c939d0e917.js"></script>
</head>
<body>
<div class="title">Store Locator</div>
<div class="search-container">
<div class="search">
<input id="zip-code-input" type="text" placeholder="Enter Zip Code"/>
<i class="fas fa-search" aria-hidden="true"></i>
</div>
</div>
<div class="stores-list-container">
<div class="stores-list">
<div class="store-container">
<div class="store-address">
<span>9100 SE 42nd St</span>
<span> Mercer Island, WA 98040</span>
</div>
<div class="store-phone-number">555-555-5555</div>
<div class="store-number-container">
<div class="store-number">
1
</div>
</div>
</div>
</div>
</div>
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=000000000000000000&callback=initMap"></script>
</body>
</html>