Visualise diff in html report - r

I would like to produce an html report which visualises the difference between a number of very similar texts. I found the diffobj package, which does what I want if used in an interactive session:
However, I can't figure out how to render this in a report. Here is what I tried so far:
---
title: "Repex"
output: html_document
---
```{r cars}
duplicates <- data.frame(text_original = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas laoreet risus et eros sagittis aliquam. Donec fringilla pharetra vestibulum. Fusce vestibulum imperdiet nibh ac rutrum. Aenean sollicitudin, tellus sed tempor varius, quam dolor ornare sapien, eu faucibus quam arcu vestibulum velit. Praesent maximus odio magna, in vulputate arcu cursus vitae. Praesent condimentum purus sit amet nisl vestibulum semper. Nunc quis eros ultricies, elementum eros sed, ullamcorper nunc. Nunc dictum commodo quam, et venenatis velit porta sit amet. Nunc et lorem et odio scelerisque vulputate sed at purus. Sed velit ipsum, consequat vel tristique tincidunt, semper in odio. Nullam pharetra laoreet velit quis sollicitudin. Fusce tellus felis, scelerisque id ipsum et, varius iaculis erat. Sed porttitor at quam sed rhoncus. Donec rutrum justo nec malesuada aliquam. Maecenas feugiat odio ac ante consequat, aliquet tempus magna tempus. Morbi convallis orci felis, ac ultricies ex dignissim in. Donec ornare vehicula ante eu interdum.",
text_duplicate = "Lorem dolor sit amet, consectetur elit. Maecenas laoreet risus et eros sagittis aliquam. Donec fringilla pharetra vestibulum. Fusce vestibulum imperdiet nibh ac rutrum. Aenean sollicitudin, tellus sed tempor varius, quam dolor ornare sapien, eu faucibus quam arcu vestibulum velit. Praesent maximus odio magna, in vulputate arcu cursus vitae. Praesent condimentum purus sit amet nisl vestibulum semper. Nunc quis eros ultricies, elementum sed, ullamcorper nunc. Nunc commodo quam, et venenatis velit porta sit amet. Nunc et lorem et odio scelerisque vulputate sed at purus. Sed velit ipsum, consequat vel tristique tincidunt, semper in odio. Nullam pharetra laoreet velit quis sollicitudin. Fusce tellus felis, scelerisque id ipsum et, varius iaculis erat. Sed porttitor at quam sed rhoncus. Donec rutrum justo nec malesuada aliquam. Maecenas feugiat odio ac ante consequat, aliquet tempus magna tempus. Morbi convallis orci felis, ac ultricies ex dignissim in. Donec ornare vehicula ante eu interdum.",
stringsAsFactors = FALSE)
library(diffobj)
for (i in 1) {
orig <- unname(unlist(quanteda::tokens(duplicates$text_original[i], what = "sentence")))
dup <- unname(unlist(quanteda::tokens(duplicates$text_duplicate[i], what = "sentence")))
diff <- diffPrint(current = orig,
target = dup,
format = "html",
interactive = FALSE)
print(diff)
}
```
The result when knitting this file is that the html code for each diff is shown but not rendered. Note, that I used the for loop with just one iteration for demonstration only. The real task is to render around 50 diffs.
Any ideas how to solve this either tweaking the settings of diffPrint() or rmarkdown?

The problem is that diffPrint doesn't output css style.
In the setup chunk, add results "asis"
```{r cars, results="asis"}
duplicates <- data.frame(text_original = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas laoreet risus et eros sagittis aliquam. Donec fringilla pharetra vestibulum. Fusce vestibulum imperdiet nibh ac rutrum. Aenean sollicitudin, tellus sed tempor varius, quam dolor ornare sapien, eu faucibus quam arcu vestibulum velit. Praesent maximus odio magna, in vulputate arcu cursus vitae. Praesent condimentum purus sit amet nisl vestibulum semper. Nunc quis eros ultricies, elementum eros sed, ullamcorper nunc. Nunc dictum commodo quam, et venenatis velit porta sit amet. Nunc et lorem et odio scelerisque vulputate sed at purus. Sed velit ipsum, consequat vel tristique tincidunt, semper in odio. Nullam pharetra laoreet velit quis sollicitudin. Fusce tellus felis, scelerisque id ipsum et, varius iaculis erat. Sed porttitor at quam sed rhoncus. Donec rutrum justo nec malesuada aliquam. Maecenas feugiat odio ac ante consequat, aliquet tempus magna tempus. Morbi convallis orci felis, ac ultricies ex dignissim in. Donec ornare vehicula ante eu interdum.",
text_duplicate = "Lorem dolor sit amet, consectetur elit. Maecenas laoreet risus et eros sagittis aliquam. Donec fringilla pharetra vestibulum. Fusce vestibulum imperdiet nibh ac rutrum. Aenean sollicitudin, tellus sed tempor varius, quam dolor ornare sapien, eu faucibus quam arcu vestibulum velit. Praesent maximus odio magna, in vulputate arcu cursus vitae. Praesent condimentum purus sit amet nisl vestibulum semper. Nunc quis eros ultricies, elementum sed, ullamcorper nunc. Nunc commodo quam, et venenatis velit porta sit amet. Nunc et lorem et odio scelerisque vulputate sed at purus. Sed velit ipsum, consequat vel tristique tincidunt, semper in odio. Nullam pharetra laoreet velit quis sollicitudin. Fusce tellus felis, scelerisque id ipsum et, varius iaculis erat. Sed porttitor at quam sed rhoncus. Donec rutrum justo nec malesuada aliquam. Maecenas feugiat odio ac ante consequat, aliquet tempus magna tempus. Morbi convallis orci felis, ac ultricies ex dignissim in. Donec ornare vehicula ante eu interdum.",
stringsAsFactors = FALSE)
library(diffobj)
for (i in 1) {
orig <- unname(unlist(quanteda::tokens(duplicates$text_original[i], what = "sentence")))
dup <- unname(unlist(quanteda::tokens(duplicates$text_duplicate[i], what = "sentence")))
diff <- diffPrint(current = orig,
target = dup,
format = "html",
interactive = FALSE)
print(diff)
}
```
Somewhere in the rmd file add
<style type="text/css">
DIV.diffobj_container PRE {
white-space: pre-wrap;
margin: 0;
}
DIV.diffobj_container DIV.row {
width: 100%;
font-family: monospace;
display: table;
table-layout: fixed;
}
DIV.diffobj_container DIV.line {
width: auto;
display: table-cell;
overflow: hidden;
}
DIV.diffobj_container DIV.line>DIV {
width: 100%;
display: table;
table-layout: auto;
}
DIV.diffobj_container DIV.line.banner>DIV {
display: table;
table-layout: auto; /* set to fixed in JS */
}
DIV.diffobj_container DIV.text {
display: table-cell;
width: 100%;
}
DIV.diffobj_container DIV.gutter {
display: table-cell;
padding: 0 0.2em;
}
DIV.diffobj_container DIV.gutter DIV {
display: table-cell;
}
#diffobj_content_meta DIV.diffobj_container DIV.row {
width: auto;
}
#diffobj_banner_meta DIV.diffobj_container DIV.line.banner>DIV {
table-layout: auto;
}
#diffobj_outer {
overflow: hidden;
}
/* Summary -------------------------------------------------------------------*/
DIV.diffobj_container DIV.summary DIV.map {
word-wrap: break-word;
padding-left: 1em;
}
DIV.diffobj_container DIV.summary DIV.detail {
padding-left: 1em;
}
/* Common elements -----------------------------------------------------------*/
DIV.diffobj_container DIV.line.banner {
font-size: 1.2em;
font-weight: bold;
overflow: hidden;
}
/* truncate banners */
DIV.diffobj_container DIV.line.banner DIV.text DIV{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%; /* need to compute and set in JS */
}
DIV.diffobj_container DIV.gutter,
DIV.diffobj_container DIV.guide,
DIV.diffobj_container DIV.fill,
DIV.diffobj_container DIV.context_sep,
DIV.diffobj_container SPAN.trim {
color: #999;
}
DIV.diffobj_container DIV.header {
font-size: 1.1em;
}
DIV.diffobj_container DIV.text>DIV.match,
DIV.diffobj_container DIV.text>DIV.guide {
background-color: #ffffff;
}
DIV.diffobj_container DIV.text>DIV.fill {
background-color: transparent;
}
DIV.diffobj_container DIV.text>DIV {
padding-right: 3px;
}
DIV.diffobj_container DIV.text>DIV {
border-left: 1px solid #888888;
}
DIV.diffobj_container DIV.line {
background-color: #eeeeee;
}
DIV.diffobj_container DIV.text>DIV,
DIV.diffobj_container DIV.header {
padding-left: 0.5em;
}
DIV.diffobj_container DIV.line>DIV.match,
DIV.diffobj_container DIV.line>DIV.fill,
DIV.diffobj_container DIV.line>DIV.guide {
border-left: 1px solid #888888;
}
/* github inspired color scheme - default ------------------------------------*/
DIV.diffobj_container.light.rgb SPAN.word.insert,
DIV.diffobj_container.light.rgb DIV.line>DIV.insert {
background-color: #a6f3a6;
}
DIV.diffobj_container.light.rgb SPAN.word.delete,
DIV.diffobj_container.light.rgb DIV.line>DIV.delete {
background-color: #f8c2c2;
}
DIV.diffobj_container.light.rgb DIV.text>DIV.insert {
background-color: #efffef;
}
DIV.diffobj_container.light.rgb DIV.text>DIV.insert,
DIV.diffobj_container.light.rgb DIV.line>DIV.insert {
border-left: 1px solid #33bb33;
}
DIV.diffobj_container.light.rgb DIV.text>DIV.delete {
background-color: #ffefef;
}
DIV.diffobj_container.light.rgb DIV.text>DIV.delete,
DIV.diffobj_container.light.rgb DIV.line>DIV.delete {
border-left: 1px solid #cc6666;
}
DIV.diffobj_container.light.rgb DIV.header {
background-color: #e0e6fa;
border-left: 1px solid #9894b6;
}
/* Yellow Blue variation -----------------------------------------------------*/
DIV.diffobj_container.light.yb SPAN.word.insert,
DIV.diffobj_container.light.yb DIV.line>DIV.insert {
background-color: #c0cfff;
}
DIV.diffobj_container.light.yb SPAN.word.delete,
DIV.diffobj_container.light.yb DIV.line>DIV.delete {
background-color: #e7e780;
}
DIV.diffobj_container.light.yb DIV.text>DIV.insert {
background-color: #efefff;
}
DIV.diffobj_container.light.yb DIV.text>DIV.insert,
DIV.diffobj_container.light.yb DIV.line>DIV.insert {
border-left: 1px solid #3333bb;
}
DIV.diffobj_container.light.yb DIV.text>DIV.delete {
background-color: #fefee5;
}
DIV.diffobj_container.light.yb DIV.text>DIV.delete,
DIV.diffobj_container.light.yb DIV.line>DIV.delete {
border-left: 1px solid #aaaa55;
}
DIV.diffobj_container.light.yb DIV.header {
background-color: #afafaf;
border-left: 1px solid #e3e3e3;
color: #e9e9e9;
}
DIV.diffobj_container.light.yb DIV.line {
background-color: #eeeeee;
}
</style>
A working example
source rmarkdown
For the record, related discussion on github

Related

Gap left of header, despite width set to 100% (CSS) [duplicate]

This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 7 months ago.
Edit
Apparently my question is similar to a question about the margin width of a document's body. Which is kind of odd, because that question itself is the answer to mine. It's the answers here which refer to that question, and since I'm asking for those answers I can't know that. Hope this makes sense.
I have a webpage with fixed header and footer, for which I set the width to 100%. Nevertheless there is an 8 pixel gap to the left of both. How do I get rid of them?
CSS
#main {
width: 1200px;
height: 100%;
margin: 60px auto 0 auto;
padding: 1em;
}
/* pertaining header ------------------------------------ */
header, #main::before {
height: 60px;
}
header {
position: fixed;
top: 0;
width: 100%;
margin: auto;
background: linear-gradient(180deg, #91C1CC, #468795);
border-bottom: 1px solid black;
}
header div {
width: 1200px;
margin: 0 auto;
padding: 0;
}
header div p {
margin-top: 16px;
margin-left: 1000px;
font-family: Whitehall, Verdana, Geneva, sans-serif;
font-size: 2.5em;
color: white;
}
/* pertaining footer ------------------------------------ */
#container::after {
content: "";
display: block;
}
footer, #main::after {
height: 40px;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
margin: auto;
background: linear-gradient(0, #91C1CC, #468795);
border-top: 1px solid black;
}
footer div {
width: 1200px;
margin: auto;
padding: 1em;
}
#departments {
margin: 0;
padding: 0 1em;
margin-top: -8px;
margin-left: -22px;
font-size: 85%;
}
#departments a {
margin-right: 3em;
color: black;
}
#departments a:link, #departments a:visited {
text-decoration: none;
}
JSfiddle at https://jsfiddle.net/stevenvh/65dao4pt/5/
The 8 pixel gap is cause by the HTML body tag, it has a default margin of 8px on all the four sides.
To get ride of all the gap around the element, just use CSS property of margin: 0; like this,
body {
/* to remove gaps from four sides */
margin: 0;
}
Working Example:
#font-face {
font-family: Whitehall;
src: url('fonts/Whitehall.woff') format('woff'), url('fonts/Whitehall.ttf') format('truetype');
}
body {
font-family: Verdana, Geneva, sans-serif;
line-height: 1.6em;
/* to remove gaps from four sides */
margin: 0;
}
#main {
width: 1200px;
height: 100%;
margin: 60px auto 0 auto;
padding: 1em;
}
/* pertaining header ------------------------------------ */
header,
#main::before {
height: 60px;
}
header {
position: fixed;
top: 0;
width: 100%;
margin: auto;
background: linear-gradient(180deg, #91C1CC, #468795);
border-bottom: 1px solid black;
}
header div {
width: 1200px;
margin: 0 auto;
padding: 0;
}
header div p {
margin-top: 16px;
margin-left: 1000px;
font-family: Whitehall, Verdana, Geneva, sans-serif;
font-size: 2.5em;
color: white;
}
/* pertaining footer ------------------------------------ */
#container::after {
content: "";
display: block;
}
footer,
#main::after {
height: 40px;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
margin: auto;
background: linear-gradient(0, #91C1CC, #468795);
border-top: 1px solid black;
}
footer div {
width: 1200px;
margin: auto;
padding: 1em;
}
#departments {
margin: 0;
padding: 0 1em;
margin-top: -8px;
margin-left: -22px;
font-size: 85%;
}
#departments a {
margin-right: 3em;
color: black;
}
#departments a:link,
#departments a:visited {
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<div id="container">
<header>
<div>
<p>Main title</p>
</div>
</header>
<div id="main">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
</div>
<footer>
<div>
<p id="departments">
◼ About ◼ Contact ◼ Sitemap
</p>
</div>
</footer>
</div>
</body>
</html>
HTML's body tag has a margin on all sides set by default. By adding margin: 0 to your body you can fix that quite easily.
#font-face {
font-family: Whitehall;
src: url('fonts/Whitehall.woff') format('woff'),
url('fonts/Whitehall.ttf') format('truetype');
}
body {
font-family: Verdana, Geneva, sans-serif;
line-height: 1.6em;
margin: 0;
}
#main {
width: 1200px;
height: 100%;
margin: 60px auto 0 auto;
padding: 1em;
}
/* pertaining header ------------------------------------ */
header, #main::before {
height: 60px;
}
header {
position: fixed;
top: 0;
width: 100%;
margin: auto;
background: linear-gradient(180deg, #91C1CC, #468795);
border-bottom: 1px solid black;
}
header div {
width: 1200px;
margin: 0 auto;
padding: 0;
}
header div p {
margin-top: 16px;
margin-left: 1000px;
font-family: Whitehall, Verdana, Geneva, sans-serif;
font-size: 2.5em;
color: white;
}
/* pertaining footer ------------------------------------ */
#container::after {
content: "";
display: block;
}
footer, #main::after {
height: 40px;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
margin: auto;
background: linear-gradient(0, #91C1CC, #468795);
border-top: 1px solid black;
}
footer div {
width: 1200px;
margin: auto;
padding: 1em;
}
#departments {
margin: 0;
padding: 0 1em;
margin-top: -8px;
margin-left: -22px;
font-size: 85%;
}
#departments a {
margin-right: 3em;
color: black;
}
#departments a:link, #departments a:visited {
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<div id="container">
<header>
<div>
<p>Main title</p>
</div>
</header>
<div id="main">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
</div>
<footer>
<div>
<p id="departments">
◼ About
◼ Contact
◼ Sitemap
</p>
</div>
</footer>
</div>
</body>
</html>
As you've set the header as position: fixed; you could add left: 0; to the header and it will force it to the left. Then you don't need to set the width.

Rotate text button in flex?

I would be grateful for advice about how to rotate a button in a flex context. I have a flex container with a "row" direction (that is, the three content items are arranged from left to right in a row), and the leftmost content item is a <div> that contains just a <button> with a few words of text in it. I want that <div> to be rendered vertically (so that the text reads from bottom to top), to hug the left edge of the container, and to be just the width of its one line of text.
The sample at https://jsfiddle.net/djbpitt/gth3nck9/74/ works as I need it to in Firefox 89, but in Chrome 90 (and Safari 14.1.1) the button is not rotated. caniuse.com tells me that vendor prefixes should not be required for CSS transform: rotate() or writing-mode: vertical-lr;, and adding a -webkit prefix doesn't seem to help anyway.
I would be grateful if someone could please advise me about how I can obtain the behavior I need in the versions of Firefox, Chrome, and Safari mentioned above (which are the latest versions as I write this). I would prefer a pure HTML/CSS (that is, no JavaScript) solution. Thank you!
html {
height: 100%;
}
body {
display: flex;
flex-direction: row;
height: 100%;
margin-left: 0;
padding-left: 0;
}
body > * {
overflow-y: auto;
height: 100vh;
}
body > section {
flex: auto;
}
div#button {
display: flex;
flex: 0 0 1em;
border: none;
justify-content: center;
transform: rotate(180deg);
margin: 0 5px 0 0;
padding: 0;
overflow: visible;
}
button {
margin: auto;
border: 1px black solid;
border-radius: 10px 0 0 10px;
padding: 3px;
}
button > span {
writing-mode: vertical-lr;
width: 1em;
margin: 3px;
}
nav {
flex: 0 0 20em;
margin-right: 1em;
padding-right: 1em;
border-right: 1px gray solid;
}
nav ul {
list-style-type: none;
padding-left: 0;
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
</head>
<body>
<div id="button">
<button><span>Rotate me!</span></button>
</div>
<nav>
<ul>
<li>first</li>
<li>section</li>
</ul>
</nav>
<main>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dignissim tristique est, et facilisis urna aliquet et. Vivamus porta laoreet mi non cursus. Integer volutpat tortor lectus, interdum gravida libero interdum ac. Curabitur malesuada cursus laoreet. Donec nec varius est, ac venenatis velit. Vivamus ac ipsum et nibh dictum dignissim. Fusce eget turpis in sem rutrum congue. Donec vitae sollicitudin nunc, elementum porta tortor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque convallis quam leo, pretium fermentum ante imperdiet sit amet. Quisque egestas risus vitae ante fermentum tincidunt. Sed consectetur efficitur tempus. Nunc tincidunt nunc sed semper accumsan. Ut eu tortor scelerisque, aliquet leo eget, ullamcorper dolor.</p>
<p>Duis non nisi vitae felis ultricies dapibus pulvinar quis ex. Nullam imperdiet, risus sed pharetra aliquam, mi nulla condimentum purus, tincidunt hendrerit ex metus vitae nisl. Nullam venenatis turpis libero, a bibendum elit venenatis ut. Aenean et orci ac metus pretium pellentesque. Phasellus sed faucibus est. Aenean a dui non augue aliquet sagittis quis at ex. Vestibulum lorem lectus, sodales efficitur lacinia id, iaculis id ante. Fusce aliquam erat libero, a ultrices dolor volutpat et. Vivamus at euismod nisl. Donec hendrerit non lacus vel mollis.</p>
<p>Phasellus gravida non nisi quis vehicula. Curabitur sagittis nec nulla eget sollicitudin. Mauris sit amet mattis ligula. Nulla pretium posuere diam vitae tempor. Aenean consequat ligula luctus quam vestibulum, vel rhoncus turpis laoreet. Etiam nec aliquam ipsum, ut tristique lorem. In nec auctor arcu. Proin sed finibus ligula. Sed scelerisque lorem ligula. Nam quis quam vehicula, hendrerit nibh nec, rhoncus elit. Praesent porttitor, tellus nec aliquam sollicitudin, justo orci sagittis nisl, non imperdiet ligula mauris sit amet eros. In dignissim placerat laoreet. Aenean ipsum lorem, aliquet id arcu id, rhoncus porta justo. Integer egestas mauris quam, eget placerat metus sagittis eget. Aenean volutpat eleifend nisi eget interdum.</p>
<p>
Vestibulum in ante lectus. Mauris luctus imperdiet facilisis. Nunc sagittis velit lacus, eget gravida arcu efficitur vitae. Sed sodales felis elit, eget volutpat dui congue sit amet. Fusce mi velit, cursus volutpat dapibus in, auctor id dolor. Maecenas convallis nisl justo. Cras sollicitudin tellus nec dui dictum finibus. Fusce nec feugiat metus. Aliquam sit amet congue nulla. Sed cursus fringilla sapien et malesuada. Duis aliquet, nunc eget consectetur fringilla, felis lectus ultrices mi, id maximus justo mauris a mi.</p>
<p>
Vivamus ac est vitae nulla dignissim posuere ac id arcu. Duis sed tortor pretium, tempus orci vel, efficitur ex. Quisque aliquet enim mattis odio tincidunt lacinia. Vestibulum blandit congue neque ac bibendum. Proin at consequat tortor, id malesuada dolor. Integer interdum purus sit amet leo venenatis, gravida porttitor ipsum eleifend. Donec venenatis maximus faucibus. Duis et magna vitae arcu malesuada sodales.</p>
</main>
</body>
</html>
The problem seems to lie with Chrome/Edge settings for button. They have for example amongst other things:
-webkit-writing-mode: horizontal-tb !important;
So this snippet gives up trying to style a button and replaces it with a div. Obviously you'll want to style that as you wish:
html {
height: 100%;
}
body {
display: flex;
flex-direction: row;
height: 100%;
margin-left: 0;
padding-left: 0;
}
body>* {
overflow-y: auto;
height: 100vh;
}
div#button {
position: relative;
display: flex;
flex: 0 0 1em;
writing-mode: vertical-lr;
border: none;
justify-content: center;
transform: rotate(180deg);
margin: 0 5px 0 0;
padding: 0;
overflow: visible;
}
#button div {
background-color: #eeeeee;
padding: 10px 5px 10px 5px;
border: 1px solid black;
border-radius: 5px;
}
nav {
flex: 0 0 20em;
margin-right: 1em;
padding-right: 1em;
border-right: 1px gray solid;
}
nav ul {
list-style-type: none;
padding-left: 0;
}
nav ul {
list-style-type: none;
padding-left: 0;
}
<div id="button">
<div>Rotate me!</div>
</div>
<nav>
<ul>
<li>first</li>
<li>section</li>
</ul>
</nav>
<main>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis dignissim tristique est, et facilisis urna aliquet et. Vivamus porta laoreet mi non cursus. Integer volutpat tortor lectus, interdum gravida libero interdum ac. Curabitur malesuada cursus
laoreet. Donec nec varius est, ac venenatis velit. Vivamus ac ipsum et nibh dictum dignissim. Fusce eget turpis in sem rutrum congue. Donec vitae sollicitudin nunc, elementum porta tortor. Class aptent taciti sociosqu ad litora torquent per conubia
nostra, per inceptos himenaeos. Pellentesque convallis quam leo, pretium fermentum ante imperdiet sit amet. Quisque egestas risus vitae ante fermentum tincidunt. Sed consectetur efficitur tempus. Nunc tincidunt nunc sed semper accumsan. Ut eu tortor
scelerisque, aliquet leo eget, ullamcorper dolor.</p>
<p>Duis non nisi vitae felis ultricies dapibus pulvinar quis ex. Nullam imperdiet, risus sed pharetra aliquam, mi nulla condimentum purus, tincidunt hendrerit ex metus vitae nisl. Nullam venenatis turpis libero, a bibendum elit venenatis ut. Aenean et
orci ac metus pretium pellentesque. Phasellus sed faucibus est. Aenean a dui non augue aliquet sagittis quis at ex. Vestibulum lorem lectus, sodales efficitur lacinia id, iaculis id ante. Fusce aliquam erat libero, a ultrices dolor volutpat et. Vivamus
at euismod nisl. Donec hendrerit non lacus vel mollis.</p>
<p>Phasellus gravida non nisi quis vehicula. Curabitur sagittis nec nulla eget sollicitudin. Mauris sit amet mattis ligula. Nulla pretium posuere diam vitae tempor. Aenean consequat ligula luctus quam vestibulum, vel rhoncus turpis laoreet. Etiam nec aliquam
ipsum, ut tristique lorem. In nec auctor arcu. Proin sed finibus ligula. Sed scelerisque lorem ligula. Nam quis quam vehicula, hendrerit nibh nec, rhoncus elit. Praesent porttitor, tellus nec aliquam sollicitudin, justo orci sagittis nisl, non imperdiet
ligula mauris sit amet eros. In dignissim placerat laoreet. Aenean ipsum lorem, aliquet id arcu id, rhoncus porta justo. Integer egestas mauris quam, eget placerat metus sagittis eget. Aenean volutpat eleifend nisi eget interdum.</p>
<p>
Vestibulum in ante lectus. Mauris luctus imperdiet facilisis. Nunc sagittis velit lacus, eget gravida arcu efficitur vitae. Sed sodales felis elit, eget volutpat dui congue sit amet. Fusce mi velit, cursus volutpat dapibus in, auctor id dolor. Maecenas
convallis nisl justo. Cras sollicitudin tellus nec dui dictum finibus. Fusce nec feugiat metus. Aliquam sit amet congue nulla. Sed cursus fringilla sapien et malesuada. Duis aliquet, nunc eget consectetur fringilla, felis lectus ultrices mi, id maximus
justo mauris a mi.</p>
<p>
Vivamus ac est vitae nulla dignissim posuere ac id arcu. Duis sed tortor pretium, tempus orci vel, efficitur ex. Quisque aliquet enim mattis odio tincidunt lacinia. Vestibulum blandit congue neque ac bibendum. Proin at consequat tortor, id malesuada dolor.
Integer interdum purus sit amet leo venenatis, gravida porttitor ipsum eleifend. Donec venenatis maximus faucibus. Duis et magna vitae arcu malesuada sodales.</p>
</main>
OP here. Thank you, A Haworth, for the pointer to the !important user agent setting for writing-mode in Webkit. I knew that browsers had default styling, of course, but I didn't realize that some of that styling apparently could not be overridden with user specifications.
Your insight led me to give up on changing the writing-mode value for the <button>, as you suggest, and I approached the task by wrapping a <span> around the text inside my <button> and specifying the writing-mode for the <span>. The new version is at https://jsfiddle.net/djbpitt/gth3nck9/86/. HTML and CSS are copied below:
<div id="button">
<button>
<span>Rotate me!</span>
</button>
</div>
I had to do some additional fiddling with the CSS to get the rendering I wanted:
html {
height: 100%;
}
body {
display: flex;
flex-direction: row;
height: 100%;
margin-left: 0;
padding-left: 0;
}
body > * {
overflow-y: auto;
height: 100vh;
}
body > section {
flex: auto;
}
div#button {
display: flex;
flex: 0 0 1em;
border: none;
justify-content: center;
transform: rotate(180deg);
margin: 0 5px 0 0;
padding: 0;
overflow: visible;
}
button {
margin: auto;
border: 1px black solid;
border-radius: 10px 0 0 10px;
padding: 3px;
}
button > span {
writing-mode: vertical-lr;
width: 1em;
margin: 3px;
}
nav {
flex: 0 0 20em;
margin-right: 1em;
padding-right: 1em;
border-right: 1px gray solid;
}
nav ul {
list-style-type: none;
padding-left: 0;
}

How to set the margin of a scrollbar

I have a div with rounded corners. It need to be scrollable.
I added the scrollbar but the corner of the scrollbar control is getting out of bound at the rounded corners of the div. Is there a way to set the margin of the scrollbar control? I was thinking of Top 10-15px and bottom 10-15px.
That is my div style:
div.consoleDiv {
position: absolute;
top: 50%;
left: 50%;
width: 600px;
height: 400px;
padding: 10px;
margin: -200px 0 0 -300px;
border: 2px solid #000;
border-radius: 15px;
-moz-border-radius: 15px;
background-color: black;
border-color: slategrey;
scrollbar-arrow-color: black;
scrollbar-3dlight-color: black;
scrollbar-track-color: black;
scrollbar-face-color: black;
scrollbar-shadow-color: lightgray;
scrollbar-base-color: lime;
overflow-y: auto;
}
I found a few solutions but they had zero impact on my scrollbar so far.
I tried those:
::-webkit-scrollbar {
width: 14px;
height: 18px;
}
::-webkit-scrollbar-thumb {
height: 6px;
border: 4px solid rgba(0, 0, 0, 0);
background-clip: padding-box;
-webkit-border-radius: 7px;
background-color: rgba(0, 0, 0, 0.15);
-webkit-box-shadow: inset -1px -1px 0px rgba(0, 0, 0, 0.05), inset 1px 1px 0px rgba(0, 0, 0, 0.05);
}
::-webkit-scrollbar-button {
width: 0;
height: 0;
display: none;
}
::-webkit-scrollbar-corner {
background-color: transparent;
}
You can apply a trick adding border radius to your scroll bar, it will fit as if it weren't overflowing its container... you will need to set the custom styles for your scroll..
div.consoleDiv {
position: absolute;
top: 10px;
left: 10px;
width: 300px;
height: 200px;
padding: 10px;
border: 2px solid #000;
border-radius: 15px;
-moz-border-radius: 15px;
background-color: black;
border-color: slategrey;
color:white;
overflow:scroll;
scrollbar-arrow-color: black;
scrollbar-3dlight-color: black;
scrollbar-track-color: black;
scrollbar-face-color: black;
scrollbar-shadow-color: lightgray;
scrollbar-base-color: lime;
overflow: auto;
}
div.consoleDiv::-webkit-scrollbar {
/* width: 14px;
height: 18px;*/
width:10px;
background:red;
margin-right:10px;
border-top-right-radius:15px;
border-bottom-right-radius:15px;
}
div.consoleDiv::-webkit-scrollbar-thumb {
background-color: darkgrey;
outline: 1px solid slategrey;
border-top-right-radius:15px;
border-bottom-right-radius:15px;
}
<div class="consoleDiv">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a tempor ligula, sed cursus lorem. Sed in urna id neque tincidunt viverra quis in enim. In ullamcorper eros nec dapibus sagittis. Praesent elementum orci dolor, ac blandit mauris placerat vitae. Duis finibus, nisi at imperdiet eleifend, lorem lacus rhoncus erat, eu dignissim elit ipsum at eros. Duis vehicula volutpat urna, vel ullamcorper neque fringilla ut. Fusce pellentesque faucibus egestas. Aenean non vulputate risus, vitae viverra metus. Praesent sit amet ligula nulla. Integer vel ex nibh. Duis placerat et urna eu imperdiet.
Fusce eget molestie lectus. Curabitur condimentum urna eget quam porta vestibulum. Integer elementum, sem vel aliquam feugiat, sem urna elementum augue, sed scelerisque est ligula eu sem. Aliquam et tellus eros. Cras egestas eleifend risus. Sed sit amet erat euismod, molestie felis quis, semper metus. Integer id dignissim nunc. Phasellus lacinia lectus et ex interdum bibendum. Maecenas convallis non nisi sit amet facilisis. In sit amet neque dapibus, pellentesque justo at, vehicula eros. Fusce mattis sollicitudin fermentum. Fusce justo ligula, malesuada quis est vel, ultrices posuere sem. Ut blandit elementum luctus.
Ut finibus arcu felis, quis semper dolor elementum quis. Suspendisse molestie ultricies ex eu bibendum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec pulvinar semper viverra. Integer sit amet efficitur nibh. In egestas vel sapien sed volutpat. Nunc lorem neque, feugiat id eros in, dapibus ultricies ipsum. Curabitur eget lectus elit.
Cras orci turpis, finibus sit amet varius et, molestie nec velit. Nam mauris nisl, faucibus vitae aliquam id, vehicula id lorem. Nam feugiat id enim in sagittis. Mauris at turpis enim. Sed non ligula id nisi pellentesque blandit ut eget purus. Nam ut orci vitae orci dictum lobortis. Sed posuere ultrices posuere. Ut sodales est id elit laoreet commodo. Quisque viverra fermentum neque, quis congue nibh tristique eu. Curabitur cursus risus in scelerisque rhoncus. Nullam odio augue, lacinia nec interdum id, eleifend ut erat. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam tempor ut odio sit amet vulputate. Ut rhoncus cursus lectus, in laoreet diam dictum at. Nullam ut gravida lorem, a congue felis. In et arcu ultricies nulla laoreet convallis at vel odio.
Mauris ex lacus, mattis eu ipsum eu, semper pharetra purus. Vestibulum imperdiet rutrum lorem a bibendum. Curabitur ornare in est ac vehicula. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas vitae bibendum libero, sed malesuada libero. Sed et urna quis justo imperdiet condimentum nec id purus. In placerat mi nibh, elementum finibus magna ullamcorper in. Vivamus nulla metus, condimentum non finibus sed, semper ac metus. Nunc accumsan nibh elit, sed fringilla risus lobortis ac.
</div>

CSS transform translate cant scroll

I've got a problem with my website where Im using transform: translate(-50%,-50%); to fix my webpage not being in the middle of the page but slightly off the middle. Now ive got a problem : I cant scroll!
Example of a working webpage and a bad one:
As you can see the text is overflowing the page. How am I able to fix this?
Full CSS code of 'innerlayer'
.innerlayer {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
transform-origin: 0 0;
background-color: dodgerblue;
box-shadow: 10px 10px 40px #6680ed;
min-width: 50%;
max-width: 50%;
border: 1px solid black;
}
html {
padding: 0;
}
body {
background-color: cornflowerblue;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
.contentlayer {
text-align: center;
}
.innerlayer {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
transform-origin: 0 0;
background-color: dodgerblue;
box-shadow: 10px 10px 40px #6680ed;
min-width: 50%;
max-width: 50%;
border: 1px solid black;
}
.header {
font-weight: bolder;
font-family: Calibri;
font-size: 30pt;
border-bottom: 1px solid black;
}
.navigation {
border-bottom: 1px solid black;
background-color: #6499f1;
}
ul {
list-style: none;
margin: 0;
padding: 10 0;
}
li {
background-color: #6499f1;
border-left: 1px solid black;
padding: 10 10;
margin-right: -4px;
font-family: Arial;
font-weight: bold;
text-decoration: none;
display: inline;
}
li:last-child {
border-right: 1px solid black;
}
li:hover {
background-color: #6490e8;
}
.body {
font-family: Arial;
}
.bodytitle {
font-weight: bolder;
font-family: Calibri;
font-size: 15pt;
padding: 5 0;
}
.bodytext {
padding: 5 5;
}
.border-bottom {
border-bottom: 1px solid black;
}
.border-top {
border-top: 1px solid black;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css">
<script src="css/jquery-3.1.1.min.js"></script>
<title>Title</title>
</head>
<body id="body">
<div class="outerlayer" id="outerlayer">
<div class="innerlayer" id="innerlayer">
<div class="contentlayer">
<div class="header">
<?php echo $obj1[0]['name'] . " [" . $_GET['id'] . "]"; ?>
</div>
<div class="navigation">
<ul>
<li>Information</li>
<li>Statistics</li>
<li>Back</li>
</ul>
</div>
<div class="body">
<div class="bodytitle border-bottom">
Background Introduction
</div>
<div class="bodytext">
</div>
<div class="bodytitle border-bottom border-top">
Economy - overview
</div>
<div class="bodytext">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam luctus facilisis sollicitudin. Donec consectetur consectetur libero sed gravida. Nulla sit amet vehicula felis. In dapibus dui odio, id venenatis ante sollicitudin at. Aenean molestie lectus leo, in egestas mi tristique sit amet. Integer faucibus feugiat feugiat. Vestibulum ac porttitor dolor.
Vestibulum consectetur ornare magna, id suscipit lectus posuere ut. In dictum ornare fringilla. Quisque convallis ac libero vel vulputate. In hendrerit dolor id dapibus auctor. Donec ac nisl quis nulla volutpat condimentum ac eu velit. Nullam pretium neque tempor luctus pretium. Fusce quis diam sollicitudin, vestibulum sapien vitae, faucibus risus. Vestibulum tincidunt libero nec auctor maximus. Sed ultrices sem at nunc condimentum egestas. Praesent eu enim bibendum, consequat neque sed, sollicitudin diam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum eget maximus leo, eu feugiat purus. Nullam semper mauris id erat rhoncus malesuada. Cras nulla diam, euismod id purus eget, ultrices efficitur velit. Donec elementum auctor ex. Nunc condimentum placerat ex eget maximus.
Quisque dignissim, erat non lobortis egestas, enim justo cursus lectus, ac semper felis diam et eros. Sed scelerisque, nulla at vehicula ullamcorper, sem est pretium nisi, in consequat sapien lorem id erat. Aenean et dolor eget velit consectetur venenatis vel sit amet tellus. Fusce in venenatis nibh, vel euismod magna. Nunc sed libero vitae urna ullamcorper iaculis. Donec massa ipsum, mattis eu sollicitudin eu, porta non arcu. In porttitor turpis at purus aliquet consequat. Aliquam massa orci, tempus et suscipit et, tincidunt eu leo. Curabitur porta felis nunc, nec porttitor arcu mollis rhoncus. Vivamus vel sapien eleifend, hendrerit diam non, feugiat orci.
Nam consectetur ante ac consectetur eleifend. Vestibulum porta, tellus ut fermentum auctor, leo orci tincidunt metus, vitae tincidunt diam ex at quam. Integer nec placerat libero. Maecenas metus est, convallis a bibendum eget, dictum sit amet nunc. Nam ut nibh blandit, porta risus dapibus, imperdiet dolor. Donec viverra lectus non eros porttitor, non eleifend est ullamcorper. Etiam sed metus in nunc mollis hendrerit. Cras nec felis purus. Morbi nec posuere velit. Vivamus interdum convallis odio, sit amet tempor eros tempor non. Praesent vulputate mi sit amet nibh convallis luctus. Suspendisse vitae nisl vitae mauris scelerisque dictum in ut libero. Nam rutrum justo ex, id luctus risus laoreet vel. Aliquam non pulvinar orci, non maximus massa. Nulla condimentum orci sollicitudin libero faucibus, in rutrum neque suscipit.
Vestibulum aliquet ornare libero, ac luctus enim cursus ut. In scelerisque feugiat felis at viverra. Nam quis neque vestibulum, accumsan lorem nec, faucibus ligula. Sed feugiat quam ex, non commodo felis rutrum in. Nunc aliquet turpis in diam efficitur, vitae bibendum sapien dictum. Cras a pulvinar enim, hendrerit consequat erat. Pellentesque viverra viverra lorem, nec mattis eros dictum sed. Proin ut metus augue. Proin quis fermentum urna. Vestibulum lobortis augue a sapien iaculis, vitae vehicula magna pharetra. In suscipit ex ipsum. Aenean id efficitur massa. Vestibulum varius consectetur purus, ac ultricies leo scelerisque quis. Duis urna nisi, vehicula semper nulla nec, pellentesque dignissim nibh.
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Add this class to your css file and the scroll bar with be shown on that div but if you want to add scroll bar on whole page like a normal page then you have to translate the div as body but try to add this css code to the css file and hope it works:
.innerlayer {
height: 100%;
overflow-y: scroll;
}

CSS border/outline who goes on top of a line of text

can somebody please advice me how to achieve borders/outline like on image i'm attaching. I have tried many thing but still no success.
You can accomplish that by using a negative margin on the header.
Not my choice of design, but possible it is.
* { margin: 0; padding: 0; }
body {
padding: 1em;
}
div {
padding: 1em;
border: 1px solid black;
}
h3 {
margin-top: -1.5em;
margin-bottom: 1em;
border-bottom: 1px solid black;
}
p {
border-left: 1px solid black;
}
<div>
<h3>Chapter</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sodales velit non ligula dictum, vitae sagittis diam maximus. Vivamus finibus, nibh sed fringilla accumsan, mi neque convallis lorem, et viverra quam libero vel risus. Maecenas varius blandit dui, et suscipit massa sodales tincidunt. Donec at dui blandit, sollicitudin elit nec, tincidunt dui. Aenean facilisis tellus et velit mollis, nec efficitur lacus volutpat. Proin dapibus odio sem, fringilla ullamcorper tellus porta eget. Nunc sed egestas enim, eget gravida urna.</p>
</div>

Resources