single contiguous outline around inline span with line-height - html

The goal is to set a single contiguous outline around a <span> nested within a <p> and <div>. I found this solution: CSS/Javascript: How to draw minimal border around an inline element? which only works if there is no line-height set on any elements. Is it possible to draw a single outline (pictured) while preserving my line height? mockup of desired result
Here's my code:
.note_text_theme {
outline: 2px solid blue;
outline-style: dashed;
}
.note_text_theme span {
border: 1px solid white;
background-color: white;
position: relative;
z-index: 1000;
}
p {
margin: 10px;
}
.text_paragraph {
font-size: 18px;
line-height: 170%;
}
<div class="text_paragraph">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id lobortis purus. Nunc nibh metus, dictum sit amet mi sed, sagittis fermentum mauris. Mauris tincidunt lectus quam, quis tincidunt mi finibus at. <span class="note_text_theme">Cras feugiat accumsan magna, vel malesuada sem pulvinar nec. Curabitur a sem quis metus sodales rhoncus. Phasellus tempus ante magna, a gravida est pellentesque sed. Nam volutpat tortor nec lobortis aliquam. Fusce ornare pharetra tristique. Cras fringilla, nunc ac lobortis posuere, libero est</span>
<span></span>blandit justo, ut placerat nisl erat viverra odio. Praesent finibus viverra neque, quis feugiat felis porttitor a. Vestibulum ante ipsum primis in faucibus orci luctus.
</p>
</div>
You'll notice that if the line-height property is commented out, the outline behaves as desired. This property is commented out in the snippet below.
.note_text_theme {
outline: 2px solid blue;
outline-style: dashed;
}
.note_text_theme span {
border: 1px solid white;
background-color: white;
position: relative;
z-index: 1000;
}
p {
margin: 10px;
}
.text_paragraph {
font-size: 18px;
//line-height: 170%;
}
<div class="text_paragraph">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id lobortis purus. Nunc nibh metus, dictum sit amet mi sed, sagittis fermentum mauris. Mauris tincidunt lectus quam, quis tincidunt mi finibus at. <span class="note_text_theme">Cras feugiat accumsan magna, vel malesuada sem pulvinar nec. Curabitur a sem quis metus sodales rhoncus. Phasellus tempus ante magna, a gravida est pellentesque sed. Nam volutpat tortor nec lobortis aliquam. Fusce ornare pharetra tristique. Cras fringilla, nunc ac lobortis posuere, libero est</span>
<span></span>blandit justo, ut placerat nisl erat viverra odio. Praesent finibus viverra neque, quis feugiat felis porttitor a. Vestibulum ante ipsum primis in faucibus orci luctus.
</p>
</div>

Add a padding to the note_text_theme to adjust for the increased line-height
.note_text_theme {
outline: 2px solid blue;
outline-style: dashed;
padding: 5px 0px;
}
.note_text_theme span {
border: 1px solid white;
background-color: white;
position: relative;
z-index: 1000;
}
p {
margin: 10px;
}
.text_paragraph {
font-size: 18px;
line-height: 170%;
}
<div class="text_paragraph">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin id lobortis purus. Nunc nibh metus, dictum sit amet mi sed, sagittis fermentum mauris. Mauris tincidunt lectus quam, quis tincidunt mi finibus at. <span class="note_text_theme">Cras feugiat accumsan magna, vel malesuada sem pulvinar nec. Curabitur a sem quis metus sodales rhoncus. Phasellus tempus ante magna, a gravida est pellentesque sed. Nam volutpat tortor nec lobortis aliquam. Fusce ornare pharetra tristique. Cras fringilla, nunc ac lobortis posuere, libero est</span>
<span></span>blandit justo, ut placerat nisl erat viverra odio. Praesent finibus viverra neque, quis feugiat felis porttitor a. Vestibulum ante ipsum primis in faucibus orci luctus.
</p>
</div>

Related

How can I move my scrollbar away from the edge?

I'm still fairly new to HTML and CSS.
Does anyone know how I can move my scroll bar just a few pixels to the left, away from the edge?
This is what it currently looks like:
Current scroll bar
And this is the CSS code I'm working with:
::-webkit-scrollbar {
width: 7px;
height: 0px;
right: 3px
}
::-webkit-scrollbar-button {
width: 10px;
height: 0px;
}
::-webkit-scrollbar-thumb {
background: #FFFFFF;
border: 5px none;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #FFFFFF;
}
::-webkit-scrollbar-thumb:active {
background: #FFFFFF;
}
::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.2);
border: 5px none;
border-radius: 2px;
}
::-webkit-scrollbar-track:hover {
background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-track:active {
background: #FFFFFF;
}
::-webkit-scrollbar-corner {
background: #FFFFFF;
}
There's a trick.
Set margin-right to the parent element.
body {
background-color: grey;
}
.container-wrapper {
border: 1px solid blue;
margin-bottom: 24px;
}
.container {
border: 1px solid red;
height: 100px;
overflow-y: auto;
margin-right: 24px;
}
::-webkit-scrollbar {
width: 7px;
height: 0px;
right: 3px;
}
::-webkit-scrollbar-button {
width: 10px;
height: 0px;
}
::-webkit-scrollbar-thumb {
background: #FFFFFF;
border: 5px none;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #FFFFFF;
}
::-webkit-scrollbar-thumb:active {
background: #FFFFFF;
}
::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.2);
border: 5px none;
border-radius: 2px;
}
::-webkit-scrollbar-track:hover {
background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-track:active {
background: #FFFFFF;
}
::-webkit-scrollbar-corner {
background: #FFFFFF;
}
<div class="container-wrapper">
<div class="container">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut nibh sit amet nisl semper condimentum ac a lectus. Mauris volutpat aliquet justo, consequat scelerisque enim laoreet in. In nibh nisi, ultricies eget augue imperdiet, blandit ultricies lacus.
Aenean turpis ex, interdum sit amet ante quis, malesuada maximus quam. Pellentesque venenatis mi eu risus mollis sagittis. Nulla facilisi. Pellentesque consectetur sagittis turpis. Maecenas eu neque scelerisque felis faucibus pellentesque. Aliquam
id mauris in lectus tincidunt aliquet. In imperdiet lacus et lorem iaculis, nec vulputate velit efficitur. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi sit amet metus arcu. Quisque id purus tortor. Nullam
vitae molestie augue, et varius orci. Aliquam erat volutpat. Suspendisse commodo quam id arcu condimentum, vitae tempor quam auctor. Aliquam sit amet bibendum dolor. Fusce maximus eleifend velit, at faucibus erat lacinia eget. Cras eget nibh nec magna
gravida dictum. Aliquam vehicula erat in pretium imperdiet. Aenean id felis in enim dignissim iaculis. Nam vel pulvinar quam. Vestibulum quis mauris hendrerit, efficitur libero et, accumsan nisl. Proin hendrerit, ligula in finibus iaculis, nisi ligula
rhoncus tortor, quis commodo sem neque non sem. Nulla sollicitudin nulla ut nibh rutrum, in hendrerit magna maximus. Quisque commodo pulvinar ipsum, nec porta magna ullamcorper ac. Donec efficitur elit eget lorem dictum, quis pretium leo congue. Aliquam
dictum leo vel tortor dapibus, sit amet viverra leo efficitur. Fusce ultricies sem quis accumsan dignissim. Phasellus aliquam nisl a malesuada tristique. Ut sed diam nec lectus pharetra gravida. Nulla vel dolor at est auctor eleifend ac nec arcu.
Suspendisse eget lobortis lacus. Nunc lobortis libero lectus, sed luctus erat eleifend sit amet. In at blandit leo. Curabitur congue mauris at ante interdum molestie. Nullam dignissim elementum purus id tempor. Donec id nisi a leo sollicitudin convallis.
Nulla quis suscipit lacus. Nam vitae ante quis nulla dignissim volutpat. Morbi nibh mi, placerat ac eleifend ac, malesuada nec ligula. Morbi finibus nibh augue, dapibus ultrices purus pretium ac. Quisque id vulputate sem, eu suscipit neque. Nunc et
augue at odio facilisis varius. Vivamus fermentum est ipsum, a tincidunt augue luctus at. Maecenas vel bibendum nunc. Quisque vitae sapien sit amet lorem gravida vehicula. Maecenas ac neque vestibulum, aliquam quam non, sagittis tellus. Nulla urna
risus, dictum sit amet ultricies ut, interdum nec ante.
</div>
</div>
If you remove borders, it looks like the scrollbar is pushed away from the right side of the viewport.
body {
background-color: grey;
}
.container-wrapper {
margin-bottom: 24px;
}
.container {
height: 100px;
overflow-y: auto;
margin-right: 24px;
}
::-webkit-scrollbar {
width: 7px;
height: 0px;
right: 3px;
}
::-webkit-scrollbar-button {
width: 10px;
height: 0px;
}
::-webkit-scrollbar-thumb {
background: #FFFFFF;
border: 5px none;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #FFFFFF;
}
::-webkit-scrollbar-thumb:active {
background: #FFFFFF;
}
::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.2);
border: 5px none;
border-radius: 2px;
}
::-webkit-scrollbar-track:hover {
background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-track:active {
background: #FFFFFF;
}
::-webkit-scrollbar-corner {
background: #FFFFFF;
}
<div class="container-wrapper">
<div class="container">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut nibh sit amet nisl semper condimentum ac a lectus. Mauris volutpat aliquet justo, consequat scelerisque enim laoreet in. In nibh nisi, ultricies eget augue imperdiet, blandit ultricies lacus.
Aenean turpis ex, interdum sit amet ante quis, malesuada maximus quam. Pellentesque venenatis mi eu risus mollis sagittis. Nulla facilisi. Pellentesque consectetur sagittis turpis. Maecenas eu neque scelerisque felis faucibus pellentesque. Aliquam
id mauris in lectus tincidunt aliquet. In imperdiet lacus et lorem iaculis, nec vulputate velit efficitur. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi sit amet metus arcu. Quisque id purus tortor. Nullam
vitae molestie augue, et varius orci. Aliquam erat volutpat. Suspendisse commodo quam id arcu condimentum, vitae tempor quam auctor. Aliquam sit amet bibendum dolor. Fusce maximus eleifend velit, at faucibus erat lacinia eget. Cras eget nibh nec magna
gravida dictum. Aliquam vehicula erat in pretium imperdiet. Aenean id felis in enim dignissim iaculis. Nam vel pulvinar quam. Vestibulum quis mauris hendrerit, efficitur libero et, accumsan nisl. Proin hendrerit, ligula in finibus iaculis, nisi ligula
rhoncus tortor, quis commodo sem neque non sem. Nulla sollicitudin nulla ut nibh rutrum, in hendrerit magna maximus. Quisque commodo pulvinar ipsum, nec porta magna ullamcorper ac. Donec efficitur elit eget lorem dictum, quis pretium leo congue. Aliquam
dictum leo vel tortor dapibus, sit amet viverra leo efficitur. Fusce ultricies sem quis accumsan dignissim. Phasellus aliquam nisl a malesuada tristique. Ut sed diam nec lectus pharetra gravida. Nulla vel dolor at est auctor eleifend ac nec arcu.
Suspendisse eget lobortis lacus. Nunc lobortis libero lectus, sed luctus erat eleifend sit amet. In at blandit leo. Curabitur congue mauris at ante interdum molestie. Nullam dignissim elementum purus id tempor. Donec id nisi a leo sollicitudin convallis.
Nulla quis suscipit lacus. Nam vitae ante quis nulla dignissim volutpat. Morbi nibh mi, placerat ac eleifend ac, malesuada nec ligula. Morbi finibus nibh augue, dapibus ultrices purus pretium ac. Quisque id vulputate sem, eu suscipit neque. Nunc et
augue at odio facilisis varius. Vivamus fermentum est ipsum, a tincidunt augue luctus at. Maecenas vel bibendum nunc. Quisque vitae sapien sit amet lorem gravida vehicula. Maecenas ac neque vestibulum, aliquam quam non, sagittis tellus. Nulla urna
risus, dictum sit amet ultricies ut, interdum nec ante.
</div>
</div>
There are different ways of solving this issue. However, I guess none of them just work exactly as you would expect.
The easiest way to solve your issue would be to give your body absolute positioning:
html {
overflow: auto;
background: blue;
}
body {
position: absolute;
top: 20px;
left: 20px;
bottom: 20px;
right: 20px;
padding: 30px;
overflow-y: scroll;
overflow-x: hidden;
}
Edit: As pointed out in the other answer you could also use margin to imitate this behavior.
You could also give your scrollbar the same border color as the background, e.g.
body {
scrollbar-width: thin;
scrollbar-color: var(--thumbBG) var(--scrollbarBG);
}
body::-webkit-scrollbar-track {
background: var(--scrollbarBG);
border-right: 15px solid blue;
}
body::-webkit-scrollbar-thumb {
background-color: var(--thumbBG) ;
border: 0px solid blue;
border-right: 15px solid blue;
}
Find more information about the Webkit Scrollbar at https://css-tricks.com/custom-scrollbars-in-webkit/

CSS column element inside bug

I used column-count, but it looks like I found a bug when an element has an absolute position and overflowed from the parent.
#master {
column-count: 2;
}
.Books {
display: table;
column-break-inside: avoid;
-webkit-column-break-inside: avoid;
}
JSFiddle
There are two issues. One, the two red elements are not balanced (see the purple line) and second, the red element dropped on the bottom.
Just add margin-top: -1px; in the .bookmarkAds class.
And margin-top: 10px; in .books class .
#master {
column-count: 2;
}
#rule {
position: absolute;
width: 100%;
height: 1px;
background: #9C27B0;
top: 7px;
left: 0;
}
.Books {
width: 100%;
font-family: tahoma;
font-size: 12px;
border: 1px solid #ddd;
line-height: 150%;
background: #FFFFF6;
float: right;
box-sizing: border-box;
padding: 5px 5px 10px 5px;
margin: 3px;
margin-top: 10px;
position: relative;
display: table;
column-break-inside: avoid;
-webkit-column-break-inside: avoid;
min-height: 200px;
}
.bookmarkAds {
margin-top: -1px;
position: absolute;
left: 4px;
color: #9e9e9e;
cursor: pointer;
text-shadow: 1px 2px 2px rgba(0, 0, 0, 0.30);
top: -10px;
font-size: 22px;
background: red;
}
<div id="rule"></div>
<div id="master">
<div class="Books">
<div id="Bookmark" class="bookmarkAds RedHeart" title="" data-id="653373">x</div>
Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.
</div>
<div class="Books">
<div id="Bookmark" class="bookmarkAds RedHeart" title="" data-id="653373">x</div>
Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.
Lorem ipsum dolor sit amet, duis mattis pharetra vehicula nec phasellus sed, vestibulum mauris porttitor ipsum nostra tellus, bibendum aliquam nibh, libero elementum ut suspendisse ante dolor sit, erat quis tellus iaculis mauris sed. Nam fusce hac in metus facilisis, dictum urna nulla nulla, metus porttitor donec irure facilisis, curabitur sed id sapien gravida, eu a dolor autem et. Varius sollicitudin odio ut, eget maecenas, lacinia lobortis adipiscing id praesent orci varius, bibendum euismod tenetur pellentesque, in justo et massa nisl. Odio quis eget mauris dui consectetuer, lorem mi quis mollis arcu, ullamcorper lobortis sem, cras urna lacus sed eu. Nec taciti aliquet, praesent risus rutrum ac, sagittis eu. Sit id a, vel ultrices parturient etiam magna at. Phasellus hendrerit lacinia ac eros.
</div>
</div>
This is the way column-count works. Add margin-top: 10px; to your .Books class and the issue will be fixed. Like this: https://jsfiddle.net/x6ms3nxr/5/
Red element dropped to the bottom is actually a part of bookmark from second column that is cut and gone to the first column.
Some additional details regarding columns support in browsers can be found here:
http://zomigi.com/blog/deal-breaker-problems-with-css3-multi-columns/

My page won't scroll down once my content goes past the footer

I'm working on a school project. I am new to html. My page won't scroll down once my content goes past the footer. How do I fix this? Why won't it scroll down? I would like to keep my footer at the bottom and I tried playing around with it but can't seem to get it right.
<!DOCTYPE html>
<html lang="en">
<head>
<title>TRIP TO LONDON</title>
<meta charset="utf-8">
<link href="layout.css" rel="stylesheet" type="text/css">
<style>
<!--
Jasmine
Web Programming 1
10/28/14
- ids can be used 1 time per html page
- classes can be used unlimited time per html page
- ids typically contain margin, width of the divs
- classes contain styles of the divs
WCAG Guidelines (Section 508) WAI > W3C
AA - Headings Navigation
AAA - large bodies of text paragraphs -->
body {
font-family: Helvetica;
}
#main{
width: 950px;
margin: 0px auto;
background-color: #ececec;
}
<!--center div-->
#banner{
width: 800px;
margin-left: 45px;
margin-right: 45px;
border: medium;
}
.bg {
background-color:#ececec;
font-size: 88.5%;
font-family: helvetica;
}
#content{
width: 850px;
margin-top: 50px;}
#left{
width: 450px;
float: left;
padding: 20px 10px 10px 20px;
}
#bottom {
width: 450px;
float: left;
padding: 20px 10px 10px 20px;
margin-top: 10px;
}
#right{
width: 300px;
float: right;
padding: 20px 10px 10px 20px;
}
#footer{
position: fixed;
right: 0;
bottom: 0;
left: 0;
padding: 8px;
background-color: #4285f4;
text-align: center;
color: white;
}
.grid1{
color: #000000;
background-color: #FFFFFF;
font-family: sans-serif;
box-shadow: 0px 2px 4px #888888;
}
.grid2{
color:#000000;
background-color: #FFFFFF;
border-style: dashed;
border-width: 5px;
border-color: #000000;
box-shadow: 0px 2px 4px #888888;
}
#banner1
{
background: #4285f4;
color: white;
position: fixed;
left: 0;
right: 0;
padding: 10px;
height: 30px;
text-align: center;
top: 0;
width: 100%;
font-family: Helvetica;
font-size: 18px;
}
</style>
</head>
<body id="body" class="bg">
<div id="main">
<div id="banner1">TRIP TO LONDON</div><!--close banner-->
<div id="content">
<div id="left" class="grid1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis turpis ut sapien egestas euismod. Pellentesque a ultricies neque. Cras sed nisl mollis, iaculis metus vel, venenatis lectus. Cras nisi orci, convallis sit amet nibh ac, vestibulum aliquet lectus. Curabitur eget cursus lorem. Praesent hendrerit in nunc non rutrum. Suspendisse ac elit vitae odio condimentum consequat. Cras a fringilla dui, dapibus lacinia quam. Sed quis sagittis ante. Quisque non congue lacus, et scelerisque arcu. Cras cursus finibus gravida. Nulla id lacus consequat, finibus quam ac, ultricies purus. Curabitur scelerisque massa id leo malesuada, vel semper quam venenatis. Fusce viverra, erat at convallis laoreet, tellus erat bibendum nulla, id dapibus tellus orci viverra leo. Cras posuere id nibh at ornare. Praesent luctus magna et lacus malesuada, id ullamcorper enim vulputate. Donec vestibulum nisi sit amet vulputate consequat. Proin ultricies mi felis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus blandit, porttitor condimentum diam.</div><!--close left-->
<div id="right" class="grid1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis turpis ut sapien egestas euismod. Pellentesque a ultricies neque. Cras sed nisl mollis, iaculis metus vel, venenatis lectus. Cras nisi orci, convallis sit amet nibh ac, vestibulum aliquet lectus. Curabitur eget cursus lorem. Praesent hendrerit in nunc non rutrum. Suspendisse ac elit vitae odio condimentum consequat. Cras a fringilla dui, dapibus lacinia quam. Sed quis sagittis ante. Quisque non congue lacus, et scelerisque arcu. Cras cursus finibus gravida. Nulla id lacus consequat, finibus quam ac, ultricies purus. Curabitur scelerisque massa id leo malesuada, vel semper quam venenatis. Fusce viverra, erat at convallis laoreet, tellus erat bibendum nulla, id dapibus tellus orci viverra leo. Cras posuere id nibh at ornare. Praesent luctus magna et lacus malesuada, id ullamcorper enim vulputate. Donec vestibulum nisi sit amet vulputate consequat. Proin ultricies mi felis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus blandit, porttitor condimentum diam.
</div><!--close right-->
<div id="bottom" class="grid1"> Donec vestibulum nisi sit amet vulputate consequat. Proin ultricies mi felis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus blandit, porttitor condimentum diam. sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, elis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus bla.
</div>
</div><!--close content-->
<div id="footer">J.O. Copyright 2014</div><!--close footer-->
</div><!--close main-->
</body>
</html>
Your content is scrolled to the bottom of your page as it is supposed to do. You can't see it because you have your footer on top of your content with a fixed position. The simple solution is to put height on your footer and add the same height as padding to the content. Or just add some padding-bottom to #content like this. And add overflow: hidden to #content so it has height. If the parent is filled with floated children element it doesn't have height. So either add overflow: hidden; or use a clearfix :)
<!DOCTYPE html>
<html lang="en">
<head>
<title>TRIP TO LONDON</title>
<meta charset="utf-8">
<link href="layout.css" rel="stylesheet" type="text/css">
<style>
<!--
Jasmine
Web Programming 1
10/28/14
- ids can be used 1 time per html page
- classes can be used unlimited time per html page
- ids typically contain margin, width of the divs
- classes contain styles of the divs
WCAG Guidelines (Section 508) WAI > W3C
AA - Headings Navigation
AAA - large bodies of text paragraphs -->
body {
font-family: Helvetica;
}
#main{
width: 950px;
margin: 0px auto;
background-color: #ececec;
}
<!--center div-->
#banner{
width: 800px;
margin-left: 45px;
margin-right: 45px;
border: medium;
}
.bg {
background-color:#ececec;
font-size: 88.5%;
font-family: helvetica;
}
#content{
width: 850px;
margin-top: 50px;
padding-bottom: 50px;
overflow: hidden;
}
#left{
width: 450px;
float: left;
padding: 20px 10px 10px 20px;
}
#bottom {
width: 450px;
float: left;
padding: 20px 10px 10px 20px;
margin-top: 10px;
}
#right{
width: 300px;
float: right;
padding: 20px 10px 10px 20px;
}
#footer{
position: fixed;
right: 0;
bottom: 0;
left: 0;
padding: 8px;
background-color: #4285f4;
text-align: center;
color: white;
}
.grid1{
color: #000000;
background-color: #FFFFFF;
font-family: sans-serif;
box-shadow: 0px 2px 4px #888888;
}
.grid2{
color:#000000;
background-color: #FFFFFF;
border-style: dashed;
border-width: 5px;
border-color: #000000;
box-shadow: 0px 2px 4px #888888;
}
#banner1
{
background: #4285f4;
color: white;
position: fixed;
left: 0;
right: 0;
padding: 10px;
height: 30px;
text-align: center;
top: 0;
width: 100%;
font-family: Helvetica;
font-size: 18px;
}
</style>
</head>
<body id="body" class="bg">
<div id="main">
<div id="banner1">TRIP TO LONDON</div><!--close banner-->
<div id="content">
<div id="left" class="grid1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis turpis ut sapien egestas euismod. Pellentesque a ultricies neque. Cras sed nisl mollis, iaculis metus vel, venenatis lectus. Cras nisi orci, convallis sit amet nibh ac, vestibulum aliquet lectus. Curabitur eget cursus lorem. Praesent hendrerit in nunc non rutrum. Suspendisse ac elit vitae odio condimentum consequat. Cras a fringilla dui, dapibus lacinia quam. Sed quis sagittis ante. Quisque non congue lacus, et scelerisque arcu. Cras cursus finibus gravida. Nulla id lacus consequat, finibus quam ac, ultricies purus. Curabitur scelerisque massa id leo malesuada, vel semper quam venenatis. Fusce viverra, erat at convallis laoreet, tellus erat bibendum nulla, id dapibus tellus orci viverra leo. Cras posuere id nibh at ornare. Praesent luctus magna et lacus malesuada, id ullamcorper enim vulputate. Donec vestibulum nisi sit amet vulputate consequat. Proin ultricies mi felis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus blandit, porttitor condimentum diam.</div><!--close left-->
<div id="right" class="grid1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis turpis ut sapien egestas euismod. Pellentesque a ultricies neque. Cras sed nisl mollis, iaculis metus vel, venenatis lectus. Cras nisi orci, convallis sit amet nibh ac, vestibulum aliquet lectus. Curabitur eget cursus lorem. Praesent hendrerit in nunc non rutrum. Suspendisse ac elit vitae odio condimentum consequat. Cras a fringilla dui, dapibus lacinia quam. Sed quis sagittis ante. Quisque non congue lacus, et scelerisque arcu. Cras cursus finibus gravida. Nulla id lacus consequat, finibus quam ac, ultricies purus. Curabitur scelerisque massa id leo malesuada, vel semper quam venenatis. Fusce viverra, erat at convallis laoreet, tellus erat bibendum nulla, id dapibus tellus orci viverra leo. Cras posuere id nibh at ornare. Praesent luctus magna et lacus malesuada, id ullamcorper enim vulputate. Donec vestibulum nisi sit amet vulputate consequat. Proin ultricies mi felis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus blandit, porttitor condimentum diam.
</div><!--close right-->
<div id="bottom" class="grid1"> Donec vestibulum nisi sit amet vulputate consequat. Proin ultricies mi felis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus blandit, porttitor condimentum diam. sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, elis. Nunc accumsan venenatis ornare. Maecenas luctus venenatis accumsan. Vestibulum sit amet augue sit amet leo sollicitudin accumsan vel non massa. Morbi sodales lacus massa, non accumsan risus tempus ut. Proin convallis auctor tortor, eu venenatis turpis congue nec. Donec quam velit, volutpat bibendum metus bla.
</div>
</div><!--close content-->
<div id="footer">J.O. Copyright 2014</div><!--close footer-->
</div><!--close main-->
</body>
</html>
if your content is going off too far below and you can't scroll it means the element containing the content isn't big enough. Try to set the element that has all the content with a larger height value (I'm guessing the body element in your case)
so in your css if:
height:800px
set it to
height:1200px
or enough to hold all the content

Div doesn't stay at the right place

I'm currently having trouble with http://jsfiddle.net/XB2r7/6/, or:
.content {
margin-right: auto;
margin-left: auto;
background-color:rgba(64,64,64,0.9);
width: 1000px;
height: auto;
padding-top: 10px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
border: 1px solid #333;
color: #fff;
overflow: auto;
margin-bottom: 20px;
box-shadow: 0px 1px 1px #333;
}
.clear {
clear: both;
}
.sidebar {
width: 23.5%;
height: auto;
display: block;
float: left;
color: #000;
padding-left: 5px;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
margin-bottom: 10px;
background-color: rgba(255,255,255,0.9);
}
.content2 {
width: 73.5%;
height: auto;
display: block;
float: right;
color: #000;
padding-left: 5px;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
margin-bottom: 10px;
background-color: rgba(255,255,255,0.9);
}
.h1 {
font-weight: bold;
}
.content hr {
border: 0;
height: 2px;
background: url('bg3.jpg');
}
As you can see at JSFiddle the sidebar is going down as I place a second content2-div. Is there a way to fix this without placing it both in other containers?
Remove float:left from .sidebar class
.sidebar {
float:left; /*remove*/
}
Demo
I've updated your fiddle.
Just removed .sidebar {float:left}
try this
<div class="content">
<div class="sidebar">
<h1>Consectetur adipiscing elit.</h1>
<hr>
Morbi vel porttitor augue, eu rhoncus massa. Vivamus venenatis, arcu at euismod semper, ipsum nunc interdum ante, in semper mauris metus eu risus. Aliquam nibh massa, venenatis in turpis vitae, tempor lacinia metus. Vestibulum sed metus ut lectus lacinia tincidunt ac eu erat. Phasellus eu fermentum lacus. Duis vitae bibendum magna, a ullamcorper libero. In hac habitasse platea dictumst. Phasellus molestie nisl id lectus blandit, ac rhoncus dui pellentesque. Praesent sit amet tempus turpis, eu elementum mauris. Sed ipsum dui, luctus eu vehicula id, eleifend nec libero. Donec.
<h1>Consectetur adipiscing elit.</h1>
<hr>
Morbi vel porttitor augue, eu rhoncus massa. Vivamus venenatis, arcu at euismod semper, ipsum nunc interdum ante, in semper mauris metus eu risus. Aliquam nibh massa, venenatis in turpis vitae, tempor lacinia metus. Vestibulum sed metus ut lectus lacinia tincidunt ac eu erat. Phasellus eu fermentum lacus. Duis vitae bibendum magna, a ullamcorper libero. In hac habitasse platea dictumst. Phasellus molestie nisl id lectus blandit, ac rhoncus dui pellentesque. Praesent sit amet tempus turpis, eu elementum mauris. Sed ipsum dui, luctus eu vehicula id, eleifend nec libero. Donec.
</div>
<div class="content2">
<h1>Duis ac felis neque. Ut leo massa, hendrerit et nulla at.</h1>
<hr>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet leo at eros convallis rhoncus. Sed malesuada tincidunt dolor, nec ornare sem tincidunt vel. Maecenas placerat ipsum eu quam semper, eu tincidunt felis fringilla. Ut placerat vehicula vulputate. Sed id ultricies odio, eu congue nisi. Vivamus venenatis mauris id urna ullamcorper, ut posuere ipsum sodales. Proin gravida varius urna eu eleifend. Praesent a interdum sapien. Cras scelerisque nisi sit amet nibh convallis bibendum a eu diam. Nam porttitor elementum fringilla. Etiam accumsan dictum metus vitae cursus.
<br><br>
Vivamus ante mi, tincidunt quis commodo tempor, consequat vel nisl. Phasellus vestibulum elit a dui laoreet, nec congue velit vulputate. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam condimentum orci sit amet orci imperdiet gravida. Proin porta luctus quam, quis bibendum urna lobortis porttitor. Pellentesque nec lobortis ipsum. Pellentesque sit amet felis quis risus luctus semper in id ante. Nullam condimentum neque eget sollicitudin interdum. Duis imperdiet enim felis, in facilisis nisl facilisis at. Aliquam ut enim vehicula ligula dignissim molestie. Quisque dignissim quis ante ut eleifend. Suspendisse vitae mi vitae ligula interdum egestas ut sed nibh.
<br><br>
Mauris sit amet egestas augue. Aliquam ultrices tristique dolor vel luctus. Vestibulum cursus eleifend magna nec varius. Sed cursus magna in mi feugiat eleifend id quis purus. Fusce sollicitudin ultricies augue ac viverra. Curabitur tempor feugiat justo eu porta. Suspendisse eu sollicitudin ipsum. Proin rutrum turpis id massa molestie sollicitudin. Maecenas sit amet justo cursus, blandit mi sit amet, scelerisque quam. Nam ut arcu fringilla, sodales nibh sed, sodales elit. Nam vel tortor sed erat interdum sollicitudin sed non libero. Donec tristique, justo id interdum fermentum, lacus augue dictum nisl, sit amet adipiscing est enim vitae neque.
</div>
<div class="content2">
<h1>Duis ac felis neque. Ut leo massa, hendrerit et nulla at.</h1>
<hr>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque aliquet leo at eros convallis rhoncus. Sed malesuada tincidunt dolor, nec ornare sem tincidunt vel. Maecenas placerat ipsum eu quam semper, eu tincidunt felis fringilla. Ut placerat vehicula vulputate. Sed id ultricies odio, eu congue nisi. Vivamus venenatis mauris id urna ullamcorper, ut posuere ipsum sodales. Proin gravida varius urna eu eleifend. Praesent a interdum sapien. Cras scelerisque nisi sit amet nibh convallis bibendum a eu diam. Nam porttitor elementum fringilla. Etiam accumsan dictum metus vitae cursus.
<br><br>
Vivamus ante mi, tincidunt quis commodo tempor, consequat vel nisl. Phasellus vestibulum elit a dui laoreet, nec congue velit vulputate. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam condimentum orci sit amet orci imperdiet gravida. Proin porta luctus quam, quis bibendum urna lobortis porttitor. Pellentesque nec lobortis ipsum. Pellentesque sit amet felis quis risus luctus semper in id ante. Nullam condimentum neque eget sollicitudin interdum. Duis imperdiet enim felis, in facilisis nisl facilisis at. Aliquam ut enim vehicula ligula dignissim molestie. Quisque dignissim quis ante ut eleifend. Suspendisse vitae mi vitae ligula interdum egestas ut sed nibh.
<br><br>
Mauris sit amet egestas augue. Aliquam ultrices tristique dolor vel luctus. Vestibulum cursus eleifend magna nec varius. Sed cursus magna in mi feugiat eleifend id quis purus. Fusce sollicitudin ultricies augue ac viverra. Curabitur tempor feugiat justo eu porta. Suspendisse eu sollicitudin ipsum. Proin rutrum turpis id massa molestie sollicitudin. Maecenas sit amet justo cursus, blandit mi sit amet, scelerisque quam. Nam ut arcu fringilla, sodales nibh sed, sodales elit. Nam vel tortor sed erat interdum sollicitudin sed non libero. Donec tristique, justo id interdum fermentum, lacus augue dictum nisl, sit amet adipiscing est enim vitae neque.
</div>
</div>
Change the order of your HTML elements:
http://jsfiddle.net/XB2r7/6/
<div class="content"></div>
<div class="sidebar"></div>
<div class="content"></div>
<div class="sidebar"></div>
try this in your css file :
.content {
margin-right: auto;
margin-left: auto;
background-color:rgba(64,64,64,0.9);
width: 1000px;
height: auto;
padding-top: 10px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
border: 1px solid #333;
color: #fff;
overflow: auto;
margin-bottom: 20px;
box-shadow: 0px 1px 1px #333;
}
.clear {
clear: both;
}
.sidebar {
width: 23.5%;
height: auto;
display: block;
color: #000;
padding-left: 5px;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
margin-bottom: 10px;
background-color: rgba(255,255,255,0.9);
}
.content2 {
width: 73.5%;
height: auto;
display: block;
float: right;
color: #000;
padding-left: 5px;
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px;
margin-bottom: 10px;
background-color: rgba(255,255,255,0.9);
}
.h1 {
font-weight: bold;
}
.content hr {
border: 0;
height: 2px;
background: url('bg3.jpg');
}
it works :

Limit bottom border extending length of page

I have the following code. Jfiddle is here. As seen, the bottom borders, what resemble <HR> tags extend the entire length of the page.
I would like to limit the borders of <h1> and <h2> tags to be only 30% of the page. While <h3> tags remain extending across the entire page. Is this possible with css?
EDIT: with a follow up question, how would I change the css on the <h3> tag so that under the border is roughly one line of white space the same size of the font as <h3>?
HTML
<HTML>
<HEAD>
<TITLE>Sample Wiki Page</TITLE>
<link rel='stylesheet' type = 'text/css' href = 'default.css' />
</HEAD>
<BODY>
<DIV id='content'>
<h3>Main Title</h3>
<h2>Sub Title</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eros odio, venenatis ut suscipit eget, vestibulum id est. Vivamus aliquet lacus sit amet enim tempus in fermentum ipsum ornare. Pellentesque tincidunt orci sed sem luctus tristique. Ut a turpis ac nisi semper luctus. Nulla mattis ornare augue, vel lacinia purus porta eu. Vestibulum pulvinar justo dolor, in ultricies tellus. Nullam semper, ante at feugiat commodo, neque eros pulvinar ante, et porttitor velit orci eu magna. Duis mattis libero vitae magna lacinia tincidunt. Vivamus placerat elit a nisi ultrices elementum. Vestibulum condimentum posuere nulla, id ornare urna mattis id. Quisque ornare risus diam. Nunc malesuada leo sit amet mauris bibendum pharetra. Integer convallis orci id lorem volutpat suscipit.
Vestibulum ac magna libero, non condimentum neque. Integer vestibulum, quam at tempus fermentum, mi odio dictum nibh, quis venenatis velit ligula laoreet massa. Fusce lobortis augue eu ante bibendum consequat eget posuere neque. Mauris dui lorem, fringilla et auctor a, eleifend id nisi. Sed nunc tortor, blandit et malesuada quis, posuere pellentesque lorem. Nunc vehicula lectus eget tortor tempus sed pharetra diam luctus. Aenean odio leo, accumsan a vestibulum ut, tincidunt in mi. Curabitur commodo venenatis dolor, ultrices placerat nibh tempor nec. Duis eget odio mi, id imperdiet lectus. Aenean luctus bibendum arcu non egestas.
</p>
<h2>Code Section</h2>
<pre>
<xmp>
<HTML>
<HEAD>
<TITLE>Sample Wiki Page</TITLE>
<link rel='stylesheet' type = 'text/css' href = 'default.css' />
</HEAD>
<BODY>
<h3>Main Title</h3>
<h2>Sub Title</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi eros odio, venenatis ut
suscipit eget, vestibulum id est. Vivamus aliquet lacus sit amet enim tempus in fermentum
ipsum ornare. Pellentesque tincidunt orci sed sem luctus tristique. Ut a turpis ac nisi
semper luctus. Nulla mattis ornare augue, vel lacinia purus porta eu. Vestibulum pulvinar
justo dolor, in ultricies tellus. Nullam semper, ante at feugiat commodo, neque eros
pulvinar ante, et porttitor velit orci eu magna. Duis mattis libero vitae magna lacinia
tincidunt. Vivamus placerat elit a nisi ultrices elementum. Vestibulum condimentum posuere
nulla, id ornare urna mattis id. Quisque ornare risus diam. Nunc malesuada leo sit amet
mauris bibendum pharetra. Integer convallis orci id lorem volutpat suscipit.
Vestibulum ac magna libero, non condimentum neque. Integer vestibulum, quam at tempus
fermentum, mi odio dictum nibh, quis venenatis velit ligula laoreet massa. Fusce lobortis
augue eu ante bibendum consequat eget posuere neque. Mauris dui lorem, fringilla et auctor
a, eleifend id nisi. Sed nunc tortor, blandit et malesuada quis, posuere pellentesque lorem
. Nunc vehicula lectus eget tortor tempus sed pharetra diam luctus. Aenean odio leo,
accumsan a vestibulum ut, tincidunt in mi. Curabitur commodo venenatis dolor, ultrices
placerat nibh tempor nec. Duis eget odio mi, id imperdiet lectus. Aenean luctus bibendum
arcu non egestas.
<h2>Code Section</h2>
<pre>
</pre>
</BODY>
</HTML>
</xmp>
</pre>
</DIV>
</BODY>
</HTML>
CSS
#content pre {
padding: 1em;
border: 1px dashed #2f6fab;
color: black;
background-color: #f9f9f9;
white-space: pre;
margin: 1em 0px;
display: block;
font-family: monospace,Courier;
line-height: 1.1em;
width:70%;
}
#content h3{
font-size: 188%;
line-height: 1.2em;
color: black;
background: none;
font-weight: normal;
margin: 0;
overflow: hidden;
padding-top: .5em;
padding-bottom: .17em;
border-bottom: 1px solid #aaa;
}
#content h1, h2 {
color: black;
background: none;
font-weight: normal;
margin: 0;
overflow: hidden;
padding-top: .5em;
padding-bottom: .17em;
border-bottom: 1px solid #aaa;
}
You can use width: 30% for your first question, and margin-bottom: 1.2em for your second.
Here is your fiddle.
You can do something like this. http://jsfiddle.net/n5qRS/1/
<h1><span>Hello World</span></h1>
css
h1 span {
color: black;
background: none;
font-weight: normal;
margin: 0;
overflow: hidden;
padding-top: .5em;
padding-bottom: .17em;
border-bottom: 1px solid #aaa;
display: block;
width: 30%;
}
as for the second question, add a margin bottom to the h3 the same as the line height of the h3.
It is very odd that you are having your h3 as a the Main Title and h2 as the subtitle (that is reversed of how it "should" be). This fiddle uses pseudo-elements to get the border.
#content h1:after, h2:after {
content: '';
display: block;
width: 30%;
height: 0;
margin: 0 auto;
border-bottom: 1px solid #aaa;
}
The margin-bottom is added in that fiddle to the h3 for your follow-up.