Changing <summary> icon background will not work - html

I am using the <summary> tag to create a basic drop down.
I have successfully styled it the way I want with an image of a plus sign as the background. However once the <details> tag has been expanded I cannot get the background image to change to a picture of a minus.
I have tried many different multiple variations. On another note does classic Edge actually support <summary>? Compatibility sites say it has been supported since v79 however of all the tutorials showing how to use it don't work in classic Edge.
Is there a way to not show the contents of the <summary> and <details> tags if the browser doesn't support them?
summary {
list-style-image: url(images/more.png);
width: 24px;
height: 24px;
margin-bottom: 5px;
}
summary::-webkit-details-marker {
background: url(images/more.png);
color: transparent;
width: 24px;
height: 24px;
margin-bottom: 10px;
}
summary:after {
list-style-image: url(images/minus.png);
}
summary::-webkit-details-marker:after {
background: url(images/minus.png);
list-style-image: url(images/minus.png);
color: transparent;
width: 24px;
height: 24px;
margin-bottom: 10px;
}
details[open] summary:after {
background: url(images/minus.png);
list-style-image: url(images/minus.png);
}
details::-webkit-details-marker[open] summary::-webkit-details-marker:after {
background: url(images/minus.png);
list-style-image: url(images/minus.png);
}

I have gone back and found a solution that seems to work in all browsers except classic Edge and IE.
Instead of using images I am creating a new marker using CSS only and then updating the contents of the "icon" using CSS.
summary {
cursor: pointer;
font: bold 1em Arial, Helvetica, sans-serif;
padding: 8px 0;
position: relative;
width: 100%;
list-style-image: none;
}
summary::-webkit-details-marker {
display: none
}
summary:after {
background: white;
border-radius: 50%;
content: "+";
border-color: #000000;
border-style: solid;
border-width: 2px;
color: #000000;
float: left;
font-size: 19px;
line-height: 24px;
vertical-align: middle;
margin: -5px 10px 0 0;
padding: 0;
text-align: center;
width: 24px;
height: 24px;
}
details[open] summary:after {
line-height: 22px;
content: "-";
}
<details>
<summary> Expand me</summary>
<br> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</details>

I hope you want something like this. if its only about a plus and minus sign , you can do this with CSS, no need of images , change the sign color in CSS as per your need
EDIT: Although I am not agree with Connexo's comment below, but in case if you want to use some other approach or the same thing and not the summary tag as he mentioned, There is one more pure CSS option available here, check the next 3 + signs, first one is with Summary tag, and next one with Input
summary {
list-style-image: url(images/more.png);
position: relative;
width: 24px;
height: 24px;
margin-bottom: 5px;
}
summary:after {position: absolute; content: ""; height: 2px; width: 15px; background-color: red; top: 50%; transform: translateY(-50%);}
summary:before {position: absolute; content: ""; height: 2px; width: 15px; background-color: red; top: 50%; transform: translateY(-50%) rotate(90deg);}
summary::-webkit-details-marker {
background: url(images/more.png);
color: transparent;
width: 24px;
height: 24px;
margin-bottom: 10px;
}
summary:after {
list-style-image: url(images/minus.png);
}
details[open] summary:before {
background: url(images/minus.png);
list-style-image: url(images/minus.png);
}
.collapsibles {margin-top: 100px;}
.collapsibles >div {
position: relative;
margin-bottom: 30px;
padding-left: 30px;
}
.collapsibles >div p {opacity: 0; height: 0;}
.collapsibles >div input {position: absolute; height: 20px; width: 20px; top: 0; left: 0; border: 0 !important; outline: none !important;
-webkit-appearance: none; cursor: pointer;}
.collapsibles >div input:after {position: absolute; content: ""; height: 2px; width: 15px; background-color: red; top: 50%; transform: translateY(-50%);}
.collapsibles >div input:before {position: absolute; content: ""; height: 2px; width: 15px; background-color: red; top: 50%; transform: translateY(-50%) rotate(90deg);}
.collapsibles >div input:checked + p{opacity: 1; height: auto;}
.collapsibles >div input:checked:before {
display: none;
}
<h2>With Summary Tag</h2>
<details>
<summary></summary>
<p>Summary Epcot is a theme park at Walt Disney World Resort featuring exciting attractions, international pavilions, award-winning fireworks and seasonal special events.</p>
</details>
<div class="collapsibles">
<h2>Without Summary Tag</h2>
<div><input type="checkbox"><p>Epcot is a theme park at Walt Disney World Resort featuring exciting attractions, international pavilions, award-winning fireworks and seasonal special events.</p></div>
<div><input type="checkbox"><p>Epcot is a theme park at Walt Disney World Resort featuring exciting attractions, international pavilions, award-winning fireworks and seasonal special events.</p></div>
<div><input type="checkbox"><p>Epcot is a theme park at Walt Disney World Resort featuring exciting attractions, international pavilions, award-winning fireworks and seasonal special events.</p></div>
</div>

Related

How do I align images inside of a container that contains a paragraph?

I have put the image inside of the paragraph tag itself and floated it right, however it moves it to the right but underlaps the container edge.
I have taken it out of the paragraph section as well and it still does the same. I have created containers as well for them. I want the image in the container with the paragraph. I have attached an image of the issue I am having as well as my css.
body {
background-image: url(../images/keyboard.jpeg);
background-repeat: no-repeat;
background-size: cover;
font-family: cursive;
}
/* GOOGLE FONTS*/
#import url('https://fonts.googleapis.com/css2?family=Cookie&family=Fuzzy+Bubbles&family=Jost:wght#700&display=swap');
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Cookie';
font-weight: 700;
}
/*ID Classes*/
#mainTitle {
color: #FFF;
font-size: 5em;
text-align: center;
text-shadow: 5px 5px 10px #17e85f;
text-decoration: underline solid;
font-family: fantasy;
}
#container {
border: 10px solid #FFF;
margin: auto;
margin-top: 10px;
padding: auto;
width: 50%;
}
#footer {
color: #FFF;
text-align: center;
border: 2px;
border-style: solid;
}
/* REUSABLE CLASSES*/
.navbar {
background-color: #0a861d;
border-radius: 30px;
text-align: center;
}
.navbar li {
display: inline-block;
list-style: none;
margin: 13px 20px;
text-align: center;
}
.navbar ul {
overflow: auto;
}
.navbar li a {
padding: 3px 3px;
text-decoration: none;
color: white;
}
.search {
float: right;
color: white;
padding: 12px 75px;
}
.navbar input {
border: 2px solid black;
border-radius: 14px;
padding: 3px 17px;
width: 129px;
}
/*SERVICES PAGE LIST*/
.servicelist ul {
line-height: 1.5em;
margin: 5px 0 15px;
padding: 0;
}
.servicelist li {
font-size: 50px;
font-weight: 500;
background-image: linear-gradient(to left, rgba(60, 154, 118, 0.91), #15c723);
color: transparent;
text-align: center;
background-clip: text;
-webkit-background-clip: text;
}
.center {
text-align: center;
}
.margin {
margin-top: 10px;
}
.scontainer {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.box {
float: left;
width: 50%;
color: #ccc;
text-align: center;
height: 50%;
font-size: 50vmin;
font-family: helvetica;
}
/* SINGLE CLASSES*/
a:hover {
box-shadow: inset 100px 0 0 0 #54b3d6;
color: white;
}
h2 {
color: #FFF;
font-size: 2em;
text-align: center;
text-shadow: 5px 5px 10px #17e85f;
text-decoration: underline solid;
font-family: fantasy;
}
p {
color: #b8dae2;
font-family: 'Helvetica Neue', sans-serif;
font-size: 1.3em;
line-height: 24px;
margin: 10px 10px 24px;
padding: 30px;
text-align: justify;
border: 3px solid #FFF;
}
.service_styling {
color: #b8dae2;
font-family: 'Helvetica Neue', sans-serif;
font-size: 1.3em;
line-height: 24px;
margin: 10px 10px 24px;
padding: 30px;
text-align: justify;
border: 3px solid #FFF;
}
.imgcontainer {
width: auto;
height: auto;
border: 2px solid red;
float: inline-end;
}
.realImgContainer {
width: auto;
height: auto;
border: 2px solid red;
float: right;
}
img {
/* max-width: 50%; */
/* max-height: 50%; */
/* border: 5px solid #FFF; */
/* margin: auto; */
/* margin-top: 10px; */
/* padding: auto; */
/* width: 50%; */
}
/*
.imgHardware{
float: right;
}
.imgSoftware{
float: right;
}
.imgApp{
float: right;
}
.imgCabling{
float: right;
}
*/
<!-- NAV BAR-->
<nav class="navbar">
<ul>
<li>Home</li>
<li>Services</li>
<li>Locations</li>
<div class="search">
<input type="text" name="search" id="search" placeholder="Search this website">
</div>
</ul>
</nav>
<h1 id="mainTitle"> Services</h1>
<!-- MAIN SECTION-->
<section id="container">
<h2> Things We Do </h2>
<div class="servicelist margin">
<h2>Hardware</h2>
<div class="service_styling">
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
<div><img class="realImgContainer" src="images/cpusocket.jpeg" alt="computer socket"></div>
</span>
</div>
<div style="clear:both"></div>
<h2>Software</h2>
<p> We provide the latest software for all kinds of fields. We work directly with vendors to get the best rate - we provide competitive rates and offer affordable and simple subscription solutions - we also carry full version software that is subscription-free.
<img class="imgSoftware" src="images/code.jpeg" alt="computer code"></p>
<h2>Application development</h2>
<p> We can create and deploy custom software for whatever task you need completed. Our seasoned developers specialize in C, C++ and Java. Allowing us to create versailte and flexible software. Our team will with work with you hand in hand to ensure you
get exactly what you need. We will also provide 24/7 maintenance as well as upgrades on all of our in house software.
<img class="imgApp" src="images/codedeveloper.jpeg" alt="someone coding"></p>
<h2>Enterprise cabling</h2>
<p> We have over 30 years of infrastructure cabling experience. We have in house techncians who can terminate and pull ethernet and fiber optic cabling. We use our own equipment and do all of our work in house - without the use of a third party. So we
can give you a fair price as well as a clean and concise debriefing of the exact work we will be doing and its core benefits.
<img class="imgCabling" src="images/switchandcable.jpeg" alt="switch and cable">
</p>
</ul>
</section>
<!-- SUB SECTION-->
<section>
</section>
<!-- FOOTER-->
<div id="footer">© 2050</div>

Using -webkit-... to create custom text color creates border in Safari

Safari seems to have a bug that when you use webkit-background-... to give text some gradient it sometimes creates a really thin border.
It's really hard to reproduce this error consistently. The problem doesn't occur on each screen size or resolution. Adding/removing a paragraph on a random place on the page sometimes solves the issue (no logic),... Especially on Safari for iOS this problem occurs.
But this is the code I am using:
<span id="text">text.</span>
#text {
font-size: 8em;
font-weight: 700;
letter-spacing: 1px;
color: #000000;
text-decoration: none;
display: block;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: linear-gradient(to right, #09D380, #0EC7D4 50%, #a4a4a4 50%);
background-size: 200% 100%;
}
This code is supposed to give the text inside the span a customized background, in this case a gradient. And that works fine. On it's own this code also does not have this issue.
The problem occurs when mixing it on a page with more content:
<!DOCTYPE html>
<html>
<head>
<title>Safari bug</title>
<link rel="icon" type="image/png" href="favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<style>
body {
font-family: Poppins, sans-serif;
width: 100%;
height: 100%;
padding: 0;
background: linear-gradient(90deg, rgba(246,246,246,1) 0%, rgba(255,255,255,1) 50%)
}
#container {
position: absolute;
top: 50%;
left: 0;
transform: translate(0, -50%);
width: 100%;
}
#inner-container {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: flex-start;
width: 90%;
}
#under-construction-half {
position: relative;
text-align: center;
}
#under-construction-half img {
width: 60%;
margin-right: 10px;
}
#logo-and-slogan-half {
text-align: left;
box-sizing: border-box;
margin-left: 50px;
}
#logo {
font-size: 8em;
font-weight: 700;
letter-spacing: 1px;
color: #000000;
text-decoration: none;
display: block;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: linear-gradient(to right, #09D380, #0EC7D4 50%, #a4a4a4 50%);
background-size: 200% 100%;
}
#slogan {
font-size: 3.5em;
margin-top: -10%;
color: #3B3B3A;
}
#text {
margin-left: 7.5%;
margin-top: 7%;
font-size: 1.5em;
}
#under-construction-title {
font-weight: 700;
color: #09DD80;
font-size: 1.3em;
}
span {
display: block;
}
#media screen and (max-width: 950px) {
#inner-container {
flex-direction: column;
margin: auto;
}
#logo-and-slogan-half {
margin-left: 0;
font-size: 60%;
}
#text {
width: 90%;
margin: auto;
font-size: 100%;
margin-top: 20%;
}
#under-construction-half {
text-align: left;
}
#under-construction-half img {
width: 50%;
}
}
</style>
</head>
<body>
<div id="container">
<div id="inner-container">
<div id="logo-and-slogan-half">
<div id="logo-and-slogan">
<span id="logo">text.</span>
</div>
</div>
</div>
<div id="text">
<span id="under-construction-title">title...</span>
<p id="under-construction-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
</div>
</body>
</html>
Demo page.
Adding a border to the span with the same color as the background of the page also solves the issue. But this is not always possible due to having for example an image as background.
I am already tweaking and fiddling with this HTML/CSS code to resolve the issue, but I can't find a solution for this bug.
You can crop few pixels around using clip-path:inset(1px). You can use a smaller or a bigger value based on your need.
You can also crop only from the top clip-path:inset(1px 0 0). The values work the same way as with padding/margin.

Padding affects container size?

See the following Codepen sample:
https://codepen.io/anon/pen/yWXRvR
Concerning the tourplaces container at the bottom of the page (see CSS section commented as Article: tour dates: tourplaces at the bottom of the CSS):
Why is it that when I arbitrarily change the left or right padding of a .place (e.g. the first .place : padding-left: 0), the .place images as well as their container suddenly become different sizes?
The .place containers then become inconsistent, having different heights. This is not what I want - I want them to stay horizontally bottom-aligned like they initially were.
Is it because the padding makes the image's width more narrow and then the height automatically adjusts along with it, making the .place content box longer?
/* General styles */
* {
box-sizing: border-box;
font-family: Arial;
}
body {
margin: 0;
}
a {
text-decoration: none;
}
/* Specific styles */
/* nav */
nav {
position: sticky;
top: 0;
z-index: 1;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #000;
overflow: hidden;
}
nav ul li {
float: left;
}
nav ul li a{
padding: 16px 24px;
color: white;
display: block;
text-transform: uppercase;
}
nav ul li a:hover {
background-color: #ccc;
}
nav ul li:nth-of-type(5) {
/*position: relative;*/
}
nav ul li:nth-of-type(5) div a {
display: block;
color: black;
text-transform: capitalize;
}
nav ul li:nth-of-type(5) div a:hover a {
background-color: #ccc;
}
nav ul li:nth-of-type(5) div {
display: none;
position: absolute;
z-index: 1;
box-shadow: 0 0 5px #aaa;
background: white;
}
nav ul li:nth-of-type(5):hover div {
display: block;
}
#search {
float: right;
}
#search i {
color: white;
padding: 16px 24px;
font-size: 18px;
transition: 0.5s ease;
}
#search i:hover {
color: #aaa;
}
.fa-sort-down {
vertical-align: text-top;
font-size: 18px;
transform: translateY(-25%);
}
/* Animation */
#bandpics {
overflow: hidden;
}
img#chicago,
img#la,
img#ny {
width: 100%;
display: block;
position: absolute;
animation-name: slide;
animation-duration: 18s;
animation-iteration-count: infinite;
}
img#chicago {
animation-delay: 6s;
}
img#la {
animation-delay: 4s;
}
img#ny {
animation-delay: 2s;
}
#keyframes slide {
0% { opacity: 1; }
22% { opacity: 1; }
33% { opacity: 0; }
88% { opacity: 1; }
100% { opacity: 1; }
}
/* Article: the band */
#band {
width: 100%;
position: relative;
margin-top: 50%;
text-align: center;
padding: 10% 30%;
background-color: white;
}
#band h2 {
text-transform: uppercase;
font-weight: 500;
letter-spacing: 0.25em;
}
#band > h4 {
font-style: italic;
font-weight: 500;
color: #888;
}
#band h4::first-letter {
text-transform: capitalize;
}
#band p {
text-align: justify;
margin-bottom: 7%;
line-height: 1.3em;
}
#bandmembers {
overflow: hidden;
}
.bandmember img {
max-width: 50%;
}
.bandmember h4 {
font-weight: 100;
}
/* Article: tour dates */
/* Article: tour dates: sales lines */
#tourdates , #tourplaces {
background-color: black;
padding: 1% 30%;
}
#tourdates h2 {
text-transform: uppercase;
font-weight: 500;
letter-spacing: 0.25em;
color: white;
text-align: center;
}
#tourdates h4 {
text-align: center;
color: #888;
font-style: italic;
}
#tourdates h4:first-letter {
text-transform: uppercase;
}
.month {
color: #888;
background-color: white;
padding: 3%;
border-bottom: 1px solid #ccc;
}
.month span:first-of-type {
text-transform: capitalize;
margin-right: 15px;
}
.month span {
display: inline-block;
}
div.month:nth-of-type(1) span:nth-of-type(2),
div.month:nth-of-type(2) span:nth-of-type(2) {
background-color: #f44336;
color: white;
padding: 5px 10px;
}
div.month:nth-of-type(1) span:nth-of-type(2)::first-letter,
div.month:nth-of-type(2) span:nth-of-type(2)::first-letter {
text-transform: uppercase;
}
div.month:last-of-type {
position: relative;
}
div.month:last-of-type span:nth-of-type(2) {
background-color: black;
color: white;
border-radius: 50%;
padding: 4px 10px;
position: absolute;
top: 50%;
right: 5%;
transform: translateY(-50%);
}
/* Article: tour dates: tourplaces */
#tourplaces {
overflow: hidden;
margin: -8px;
}
.place {
float: left;
width: 33.33333%;
background-clip: content-box;
background-color: white;
padding-left: 8px;
padding-right: 8px;
}
.place img {
width: 100%;
}
.place img:hover {
opacity: 0.60;
}
.place-info {
padding-left: 8px;
padding-right: 8px;
padding-bottom: 8px;
}
.place-info > *:not(p) {
text-transform: capitalize;
}
.place-info h4 {
white-space: nowrap;
}
.place-info h4:nth-of-type(2) {
color: #888;
font-weight: 400;
}
.place button {
background-color: black;
color: white;
padding: 10px;
}
#media only screen and (min-width: 1000px) {
#band {
padding: 5% 30%;
}
.bandmember {
float: left;
width: 33.33333%
}
.bandmember img {
max-width: 60%;
}
}
<!-- from:
https://www.w3schools.com/w3css/tryw3css_templates_band.htm#
-->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<nav>
<ul>
<li>home</li>
<li>band</li>
<li>tour</li>
<li>contact</li>
<li>more <i class="fas fa-sort-down"></i>
<div>
merchandise
extras
media
</div>
</li>
<li id="search">
<i class="fas fa-search"></i>
</li>
</ul>
</nav>
<div id="container">
<div id="bandpics">
<img id="chicago" src="https://www.w3schools.com/w3images/chicago.jpg" alt="Chicago">
<img id="la" src="https://www.w3schools.com/w3images/la.jpg" alt="LA">
<img id="ny" src="https://www.w3schools.com/w3images/ny.jpg" alt="NY">
</div>
<article id="band">
<h2>the band</h2>
<h4>we love music</h4>
<p>We have created a fictional band website. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<div id="bandmembers">
<div class="bandmember">
<h4>name</h4>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="bandmember">
</div>
<div class="bandmember">
<h4>name</h4>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="bandmember">
</div>
<div class="bandmember">
<h4>name</h4>
<img src="https://www.w3schools.com/w3images/bandmember.jpg" alt="bandmember">
</div>
</div>
</article>
<article id="tourdates">
<h2>tour dates</h2>
<h4>remember to book your tickets!</h4>
<div class="month">
<span>september</span><span>sold out</span>
</div>
<div class="month">
<span>october</span><span>sold out</span>
</div>
<div class="month">
<span>november</span><span>3</span>
</div>
</article>
<article id="tourplaces">
<div class="place">
<img src="https://www.w3schools.com/w3images/newyork.jpg" alt="NY">
<div class="place-info">
<h4>new york</h4>
<h4>fri 27 nov 2016</h4>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.
</p>
<button>buy tickets</button>
</div>
</div>
<div class="place">
<img src="https://www.w3schools.com/w3images/paris.jpg" alt="Paris">
<div class="place-info">
<h4>paris</h4>
<h4>sat 28 nov 2016</h4>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.
</p>
<button>buy tickets</button>
</div>
</div>
<div class="place">
<img src="https://www.w3schools.com/w3images/sanfran.jpg" alt="San Francisco">
<div class="place-info">
<h4>san francisco</h4>
<h4>sun 29 nov 2016</h4>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.
</p>
<button>buy tickets</button>
</div>
</article>
</div>
Padding affects container size?
It depends, in this case it does, but only the height, not the width, since the width is defined.
Is it because the padding makes the image's width more narrow and then
the height automatically adjusts along with it, making the .place
content box longer?
That is partially correct, it does affect the size of the image and also affects the text inside, making the height bigger or smaller depending on the value of the padding.
It is difficult to see how the width of the container is not changing because you have background-clip: content-box; this makes the background clipping on the limits of the content, then there is a part of the container that you are not able to see, if you put a border, lets say border: 1px solid red; within your .place class you would be able to see left and right paddings.
For this case I would use flex or grid, a grid example: (notice that I defined the height of the first container to 500px and the others are stretching itself to fill all the remaining space)
/* General styles */
* {
box-sizing: border-box;
font-family: Arial;
}
body {
margin: 0;
}
a {
text-decoration: none;
}
#tourdates , #tourplaces {
background-color: black;
padding: 1% 10%;
}
/* Article: tour dates: tourplaces */
#tourplaces {
overflow: hidden;
margin: -8px;
display: grid;
grid-template-columns: repeat(3, 1fr)
}
.place {
background-clip: content-box;
background-color: white;
padding-left: 8px;
padding-right: 8px;
border: 1px solid red;
}
.place.first-place{
padding-left: 25px;
height: 500px
}
.place.second-place{
padding-left: 0px
}
.place img {
width: 100%;
}
.place img:hover {
opacity: 0.60;
}
.place-info {
padding-left: 8px;
padding-right: 8px;
padding-bottom: 8px;
}
.place-info > *:not(p) {
text-transform: capitalize;
}
.place-info h4 {
white-space: nowrap;
}
.place-info h4:nth-of-type(2) {
color: #888;
font-weight: 400;
}
.place button {
background-color: black;
color: white;
padding: 10px;
}
<article id="tourplaces">
<div class="place first-place">
<img src="https://www.w3schools.com/w3images/newyork.jpg" alt="NY">
<div class="place-info">
<h4>new york</h4>
<h4>fri 27 nov 2016</h4>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.
</p>
<button>buy tickets</button>
</div>
</div>
<div class="place second-place">
<img src="https://www.w3schools.com/w3images/paris.jpg" alt="Paris">
<div class="place-info">
<h4>paris</h4>
<h4>sat 28 nov 2016</h4>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.
</p>
<button>buy tickets</button>
</div>
</div>
<div class="place">
<img src="https://www.w3schools.com/w3images/sanfran.jpg" alt="San Francisco">
<div class="place-info">
<h4>san francisco</h4>
<h4>sun 29 nov 2016</h4>
<p>Praesent tincidunt sed tellus ut rutrum sed vitae justo.
</p>
<button>buy tickets</button>
</div>
</article>

Trying to create fixed transparent menu but want h1 to be centered for responsive design and .intro to be moved down without making a gap

I am trying to create a fixed nav. For the most part, it works. But I want to center the h1 for responsive design. I could just push it away from the burger menu but then it wouldn't be responsive and bang in the middle.
Also I would like to push the .intro paragraph down away from the top. But every time I do a margin gap appears at the top, and I can't for the life of me remember how to get rid of this.
Thank you to anyone who takes a look. Means a lot! Hopefully one day I can repay the favor!
Below is my HTML and CSS. I also used a standard normalize.css, and some Js but I don't think you will need that. If you do, let me know:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The Code Review</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/styles.css">
<link href="https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i" rel="stylesheet">
</head>
<body>
<header>
<!-- Introduction -->
<div class="background">
<nav class="navbar">
<span class="open-slide" onclick="openSideMenu()">
<!-- <a href="#" onclick="openSideMenu()">-->
<svg width="30" height="30">
<path d="M0,5 30,5" stroke="#000" stroke-width="4"/>
<path d="M0,14 30,14" stroke="#000" stroke-width="4"/>
<path d="M0,23 30,23" stroke="#000" stroke-width="4"/>
</svg>
<!-- </a>-->
</span>
<div id="main">
<h1>Luke Bennett</h1>
</div>
<!--
<ul class="navbar-nav">
<li>Home</li>
<li>About</li>
<li>Portfolio</li>
<li>Resume</li>
<li>Contact</li>
</ul>
-->
</nav>
<!-- Side Navigation Bar -->
<div id="side-menu" class="side-nav">
<span class="btn-close exit" onclick="closeSideMenu()">×</span>
Home
<a onclick="closeSideMenu()" href="#about">About</a>
<a onclick="closeSideMenu()" href="#portfolio-link">Portfolio</a>
<a onclick="closeSideMenu()" href="#resume-link">Resume</a>
<a onclick="closeSideMenu()" href="#contact">Contact</a>
</div>
<p class="intro">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</header>
<main>
<!-- About Me -->
<div class="about-me"><a id="about"></a>
<h2>About Me</h2>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
</div>
<!-- Portfolio -->
<div class="portfolio"><a id="portfolio-link"></a>
<h2>Portfolio</h2>
<!-- Front Page -->
<img src="img/well-being/well-being.png" alt="Donjas-Well-Being-For-Kids"/>
</div>
<!-- Resume -->
<div class="resume">
Download Resume
</div>
<!-- Contact Form -->
<div class="contact-form"><a id="contact"></a>
<form>
<fieldset>
<legend>Contact Form</legend>
<ul>
<li>
<label for="name">Name</label>
<input required type="text" id="name" name="full_name" placeholder="Required">
</li>
<li>
<label for="email">Email</label>
<input required type="text" id="email" name="email_address" placeholder="Required">
</li>
<li>
<label for="message">Message</label>
<textarea id="message" name="other_topics"></textarea>
</li>
<button type="submit">Hello!</button>
</ul>
</fieldset>
</form>
</div>
</main>
<footer>
<p>My name is Luke Bennett and I am a Human - Luke Bennett</p>
</footer>
<script src="javascript/menu.js"></script>
*,
input,
textarea,
button {
font-family: 'Lato', sans-serif;
}
h1 {
font-size: 1.7rem;
font-weight: 300;
letter-spacing: 3px;
}
h2 {
font-size: 1.4rem;
font-weight: 700;
letter-spacing: 2px;
}
p {
letter-spacing: 1px;
}
ul {
list-style: none;
padding: 0;
}
a {
text-decoration: none;
}
/************************************************************
HEADER
*************************************************************/
.navbar {
display: flex;
position: fixed;
overflow: hidden;
height: 40px;
padding: 16px 16px;
align-items: center;
}
#main {
margin: 0 auto;
}
#main a {
color: black;
}
.background {
background: linear-gradient(0deg, #fff, transparent 40%),
#333333 url('../img/sophie.jpg') no-repeat center;
background-size: cover;
padding-bottom: 50%;
margin-bottom: 30px;
}
.intro {
background: white;
opacity: 0.65;
line-height: 40px;
letter-spacing: 4px;
padding: 20px;
margin: 0 15% 15%;
}
/************************************************************
SIDE NAV
*************************************************************/
svg {
padding-top: 3px;
transition: 1s;
/*
border: 1px solid black;
border-radius: 50%;
*/
}
svg:hover {
opacity: 0.3;
}
.side-nav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #333333;
opacity: 0.9;
overflow-x: hidden;
text-align: center;
transition: 0.5s;
padding-top: 90px;
}
.side-nav a,
.btn-close {
display: block;
font-weight: 400;
color: white;
padding: 15px;
transition: 1s;
}
.side-nav a:hover,
.btn-close:hover {
background: white;
color: black;
font-weight: 400;
cursor: pointer;
}
.side-nav .btn-close {
position: absolute;
top: 0;
right: 22px;
font-size: 36px;
margin-left: 50px;
}
/************************************************************
MAIN
*************************************************************/
main {
margin-bottom: 0
}
.about-me {
margin-bottom: 40px;
}
.about-me h2 {
margin-bottom: 30px;
}
.about-me h2,
.about-me p {
text-align: center;
margin-left: 10%;
margin-right: 10%;
}
.about-me p {
font-weight: 300;
margin-bottom: 0px;
}
/************************************************************
PORTFOLIO
*************************************************************/
.portfolio {
background: #DCEAF5;
text-align: center;
padding: 20px 20px 50px;
}
.portfolio h2 {
color: black;
margin-bottom: 40px;
}
.portfolio img {
width: 80%;
padding: 3px;
transition: 1s;
margin-bottom: 10px;
border: 2px solid grey;
}
.portfolio img:hover {
opacity: 0.6;
}
/************************************************************
RESUME
*************************************************************/
/* #DCEAF5 #659EB8 */
.resume {
display: flex;
background: #969DA3;
padding: 10%;
}
.resume a {
display: block;
background: #DCEAF5;
color: black;
font-size: 1.2rem;
text-align: center;
margin: auto;
padding: 7%;
border-radius: 5px;
transition: 0.5s;
}
.resume a:hover {
opacity: 0.6;
}
/************************************************************
CONTACT
*************************************************************/
.contact-form {
background: #cc8c33;
height: 500px;
padding: 20% 10%;
}
fieldset {
border: 0;
}
legend {
font-size: 1.5rem;
font-weight: 400;
text-align: center;
color: white;
}
label {
display: block;
color: white;
margin-bottom: 10px;
}
input,
textarea {
box-sizing: border-box;
border-radius: 5px;
padding: 10px;
}
input:focus,
textarea:focus {
border: 2px solid #969DA3;
outline: none;
}
input {
border-style: none;
width: 100%;
border: 2px solid #cc8c33;
margin-bottom: 10px;
transition: 0.5s;
}
::placeholder {
text-align: right;
font-style: italic;
font-size: 0.7rem;
padding-right: 1px;
}
/* Textarea styling */
textarea {
height: 110px;
resize: none;
width: 100%;
margin-bottom: 30px;
border: 2px solid #cc8c33;
}
/* Button styling */
button {
border: none;
background: lightblue;
color: white;
font-weight: 700;
font-size: 1.1rem;
letter-spacing: 1px;
width: 100%;
border-radius: 5px;
padding: 20px;
transition: 0.5s;
}
button:hover {
background: #DCEAF5;
color: black;
}
/************************************************************
SOCIAL
*************************************************************/
footer {
background: lightblue;
height: 500px;
}

There is no scroll bar on my website, I cannot scroll with the scroll wheel [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
i am making a website and i have noticed that i cannot scroll using the scroll wheel on a mouse. I can use two-finger scrolling on my chromebook but not the scroll wheel on my pc. The issue is with both of the browsers i use; firefox and chrome.
Thanks in advance, Liam
css:
header {
width: 100%;
}
body {
margin: 0;
overflow: hidden;
}
footer {
clear: both;
height: 100px;
width: 100%;
background-color: #3d3d3d;
position: relative;
}
.nav {
width: 100%;
height: 50px;
background-color: #3D3D3D;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0)
}
.navwrap{
position: fixed;
width: 100%;
}
.name-logo {
width: 100%;
height: 350px;
background-color: #4BD150;
overflow: hidden;
}
.content {
float: left;
background-color: #f5fafa;
padding-left: 3%;
padding-right: 2%;
border-right: 4px solid #F5f5f5;
width: calc(65% - 4px);
z-index: 1;
height: 300px;
}
.sidebar {
width: 30%;
float: right;
background-color: #f5fafa;
height: 300px;
}
.social {
width: 30%;
float: right;
}
.social-icon {
float: right;
padding-left: 10px;
padding-top: 15px;
width: 35px;
}
#facebook {
padding-right: 15px;
}
.coppyright {
color: #fff;
padding-left: 25px;
width: 40%;
float: left;
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
.name {
width: 60%;
height: 100%;
padding-left: 100px;
}
.helper {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.logo {
width: 60%;
height: 100%;
float: right;
white-space:nowrap;
margin-top: 20px;
margin-right: 20%;
margin-left: 20%;
}
.logo-img {
width: 100%;
vertical-align: middle;
}
#nav {
width: 100%;
float: left;
margin: 0;
padding: 0;
list-style: none;
height: 50px;
}
#nav li {
float: left;
font-family: Ubuntu, sans-serif;
font-size: 20px;
}
#nav li a {
display: block;
padding-left: 15px ;
padding-right: 15px;
padding-top: 11px;
text-decoration: none;
font-weight: bold;
color: #fff;
height: 50px;
width: auto;
}
#nav li a:hover {
color: #fff;
background-color: #333333;
height: 39px;
}
#home {
margin-left: 20px;
}
html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin">
<title>Hackapi Mockup</title>
</head>
<!--This is where the navbar and splash title goes-->
<body><header>
<div class="navwrap">
<div class="nav">
<ul id="nav">
<li id="home">Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
</ul>
</div>
</div>
<div class="name-logo">
<div class="logo">
<span class="helper"></span>
<img class="logo-img" src="https://imagizer.imageshack.us/v2/821x224q90/674/hloZoz.png">
</div>
</div>
</header>
<!--Main content and sidebar-->
<div class="content">
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="sidebar">
</div>
<!--Here is where all extra links, coppyrights and social media links go-->
<footer>
<div class="coppyright">
<h4>Coppyright Hackapi 2014</h4>
</div>
<div calss="social">
<img id="facebook" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/538/Kk3S3f.png">
<img id="twitter" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/913/xP6ctI.png">
<img id="gplus" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/536/nkHuql.png">
<img id="ytube" class="social-icon" src="https://imagizer.imageshack.us/v2/128x128q90/906/Sct7fy.png">
</div>
</footer>
</body>
I believe it is due to this style:
body {
overflow: hidden;
margin: 0;
}
You have to remove overflow:hidden as it is preventing the scrollbars from showing.
CSS:
overflow: auto;
OR
overflow-y: auto;
on body {}