I'm trying to add left & right padding to the details text when the details block is open, without the padding the text runs right up to the edge of the background and looks crowded. However, when adding the left & right padding, the summary section shrinks on both sides by that amount.
I tried adding border-box sizing to the details, which did help with the element not expanding beyond 100% width when open, but I can't figure out how to keep the summary bar at 100% width too.
summary.accordion-button {
display: revert;
}
details.accordion-button {
width: 100%;
margin-bottom: 1rem;
padding-bottom: 0.2rem;
border-radius: var(--buttons-radius);
padding-left: 1em;
padding-right: 1em;
box-sizing: border-box;
}
summary.accordion-button > * {
display: inline;
}
summary.accordion-button:not([open]) {
text-indent: 0.5em;
list-style: revert;
padding: 0.5rem;
background-color: transparent;
border-radius: var(--buttons-radius);
border: var(--buttons-border-width) solid
rgb(var(--color-base-outline-button-labels));
box-shadow: var(--buttons-shadow-horizontal-offset)
var(--buttons-shadow-vertical-offset) var(--buttons-shadow-blur-radius)
rgba(var(--color-shadow), var(--buttons-shadow-opacity));
}
details.accordion-button:not([open]):hover summary {
background: rgb(var(--color-base-text));
color: rgb(var(--color-base-solid-button-labels)); /* marker */
box-shadow: var(--buttons-shadow-horizontal-offset)
var(--buttons-shadow-vertical-offset)
calc(var(--buttons-shadow-blur-radius) * 1.2)
rgba(var(--color-base-accent-1), calc(var(--buttons-shadow-opacity) * 1.25));
}
details.accordion-button:not([open]):hover h4 {
color: rgb(var(--color-base-solid-button-labels));
font-size: 1.2em;
letter-spacing: 0.1em;
}
details.accordion-button[open] {
background: rgba(var(--color-base-text), 0.15);
box-shadow: var(--buttons-shadow-horizontal-offset)
var(--buttons-shadow-vertical-offset) var(--buttons-shadow-blur-radius)
rgba(var(--color-shadow), var(--buttons-shadow-opacity));
}
details.accordion-button[open] h4 {
color: rgb(var(--color-base-solid-button-labels));
font-size: 1.2em;
letter-spacing: 0.1em;
}
details.accordion-button[open] summary {
border-radius: var(--buttons-radius) var(--buttons-radius) 0 0;
background: rgb(var(--color-base-text));
border: none;
letter-spacing: 0.1em;
color: rgb(var(--color-base-solid-button-labels));
box-shadow: none;
}
.accordion-button summary::-webkit-details-marker,
.accordion-button summary::marker {
display: revert;
}
details.accordion-button::-webkit-details-marker:hover,
details summary[open].accordion-button::marker:hover {
color: rgb(var(--color-base-solid-button-labels));
}
/* variables */
:root {
--buttons-radius: 8px;
--buttons-border-width: 2px;
--buttons-border-opacity: 1;
--buttons-shadow-horizontal-offset: 0px;
--buttons-shadow-vertical-offset: 0px;
--buttons-shadow-blur-radius: 0px;
--color-base-text: 68, 34, 115;
--color-base-outline-button-labels: 68, 34, 155;
--color-base-solid-button-labels: 255, 255, 255;
}
/*-------- v2 oddities */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
/*-------- v3 oddities */
summary {
cursor: pointer;
list-style: none;
position: relative;
}
summary .icon-caret {
position: absolute;
height: 0.6rem;
right: 1.5rem;
top: calc(50% - 0.2rem);
}
summary::-webkit-details-marker {
display: none;
}
body,
h1,
h2,
h3,
h4,
h5 {
font-family: sans-serif;
color: #442273;
}
<section>
<h3>Section_Header</h3>
<details class="accordion-button">
<summary class="accordion-button">
<h4>Question_1</h4>
</summary>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vestibulum morbi blandit cursus risus. Malesuada fames ac turpis egestas integer eget. Curabitur gravida arcu ac tortor dignissim
convallis aenean et tortor. Varius vel pharetra vel turpis nunc eget. Velit scelerisque in dictum non consectetur a erat. Eget duis at tellus at urna. Porttitor eget dolor morbi non arcu risus quis. Gravida arcu ac tortor dignissim convallis. Mauris
cursus mattis molestie a iaculis. Laoreet non curabitur gravida arcu. Nunc non blandit massa enim nec dui nunc mattis enim. Egestas quis ipsum suspendisse ultrices gravida. Sit amet purus gravida quis blandit turpis. Mauris vitae ultricies leo integer
malesuada nunc vel risus. Risus viverra adipiscing at in. Dictumst quisque sagittis purus sit amet volutpat consequat mauris nunc. Non quam lacus suspendisse faucibus interdum. Sed sed risus pretium quam vulputate dignissim suspendisse in. Sit amet
consectetur adipiscing elit pellentesque habitant.</p>
<p>Malesuada fames ac turpis egestas sed. Auctor augue mauris augue neque gravida in fermentum et. Risus sed vulputate odio ut enim blandit volutpat maecenas. Interdum consectetur libero id faucibus. Orci ac auctor augue mauris augue neque gravida in.
Sagittis vitae et leo duis ut diam quam nulla. Odio pellentesque diam volutpat commodo sed. In fermentum et sollicitudin ac orci. Sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit. Mi quis hendrerit dolor magna eget est lorem
ipsum. Volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque. Tellus in hac habitasse platea. Vestibulum mattis ullamcorper velit sed ullamcorper morbi. Aliquam eleifend mi in nulla posuere. Diam sollicitudin tempor id eu
nisl nunc. Velit laoreet id donec ultrices tincidunt arcu non sodales neque. Aliquet eget sit amet tellus cras adipiscing enim eu turpis. Hac habitasse platea dictumst vestibulum rhoncus. Eu sem integer vitae justo eget magna fermentum iaculis eu.</p>
</details>
</section>
A quick solution would be wrapping the details text (those p elements) into a div element and apply the padding for that new div instead of the details element.
summary.accordion-button {
display: revert;
}
details.accordion-button {
width: 100%;
margin-bottom: 1rem;
border-radius: var(--buttons-radius);
// padding-bottom: 0.2rem; /** no longer needed here */
// padding-left: 1em; /** no longer needed here */
// padding-right: 1em; /** no longer needed here */
box-sizing: border-box;
}
/** apply the padding for the "wrapper" div */
.wrapper {
padding: 1em;
}
/** remove margins on the "p" elements */
.wrapper>p {
margin: 0
}
/** only have a bottom margin to visually separate the text that doesn't apply to the last "p" element so that it doesn't ruin the padding on ".wrapper" div */
.wrapper>p:not(:last-child) {
margin-bottom: 1em;
}
summary.accordion-button>* {
display: inline;
}
summary.accordion-button:not([open]) {
text-indent: 0.5em;
list-style: revert;
padding: 0.5rem;
background-color: transparent;
border-radius: var(--buttons-radius);
border: var(--buttons-border-width) solid rgb(var(--color-base-outline-button-labels));
box-shadow: var(--buttons-shadow-horizontal-offset) var(--buttons-shadow-vertical-offset) var(--buttons-shadow-blur-radius) rgba(var(--color-shadow), var(--buttons-shadow-opacity));
}
details.accordion-button:not([open]):hover summary {
background: rgb(var(--color-base-text));
color: rgb(var(--color-base-solid-button-labels));
/* marker */
box-shadow: var(--buttons-shadow-horizontal-offset) var(--buttons-shadow-vertical-offset) calc(var(--buttons-shadow-blur-radius) * 1.2) rgba(var(--color-base-accent-1), calc(var(--buttons-shadow-opacity) * 1.25));
}
details.accordion-button:not([open]):hover h4 {
color: rgb(var(--color-base-solid-button-labels));
font-size: 1.2em;
letter-spacing: 0.1em;
}
details.accordion-button[open] {
background: rgba(var(--color-base-text), 0.15);
box-shadow: var(--buttons-shadow-horizontal-offset) var(--buttons-shadow-vertical-offset) var(--buttons-shadow-blur-radius) rgba(var(--color-shadow), var(--buttons-shadow-opacity));
}
details.accordion-button[open] h4 {
color: rgb(var(--color-base-solid-button-labels));
font-size: 1.2em;
letter-spacing: 0.1em;
}
details.accordion-button[open] summary {
border-radius: var(--buttons-radius) var(--buttons-radius) 0 0;
background: rgb(var(--color-base-text));
border: none;
letter-spacing: 0.1em;
color: rgb(var(--color-base-solid-button-labels));
box-shadow: none;
}
.accordion-button summary::-webkit-details-marker,
.accordion-button summary::marker {
display: revert;
}
details.accordion-button::-webkit-details-marker:hover,
details summary[open].accordion-button::marker:hover {
color: rgb(var(--color-base-solid-button-labels));
}
/* variables */
:root {
--buttons-radius: 8px;
--buttons-border-width: 2px;
--buttons-border-opacity: 1;
--buttons-shadow-horizontal-offset: 0px;
--buttons-shadow-vertical-offset: 0px;
--buttons-shadow-blur-radius: 0px;
--color-base-text: 68, 34, 115;
--color-base-outline-button-labels: 68, 34, 155;
--color-base-solid-button-labels: 255, 255, 255;
}
/*-------- v2 oddities */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
/*-------- v3 oddities */
summary {
cursor: pointer;
list-style: none;
position: relative;
}
summary .icon-caret {
position: absolute;
height: 0.6rem;
right: 1.5rem;
top: calc(50% - 0.2rem);
}
summary::-webkit-details-marker {
display: none;
}
body,
h1,
h2,
h3,
h4,
h5 {
font-family: sans-serif;
color: #442273;
}
<section>
<h3>Section_Header</h3>
<details class="accordion-button">
<summary class="accordion-button">
<h4>Question_1</h4>
</summary>
<div class="wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vestibulum morbi blandit cursus risus. Malesuada fames ac turpis egestas integer eget. Curabitur gravida arcu ac tortor dignissim
convallis aenean et tortor. Varius vel pharetra vel turpis nunc eget. Velit scelerisque in dictum non consectetur a erat. Eget duis at tellus at urna. Porttitor eget dolor morbi non arcu risus quis. Gravida arcu ac tortor dignissim convallis.
Mauris cursus mattis molestie a iaculis. Laoreet non curabitur gravida arcu. Nunc non blandit massa enim nec dui nunc mattis enim. Egestas quis ipsum suspendisse ultrices gravida. Sit amet purus gravida quis blandit turpis. Mauris vitae ultricies
leo integer malesuada nunc vel risus. Risus viverra adipiscing at in. Dictumst quisque sagittis purus sit amet volutpat consequat mauris nunc. Non quam lacus suspendisse faucibus interdum. Sed sed risus pretium quam vulputate dignissim suspendisse
in. Sit amet consectetur adipiscing elit pellentesque habitant.</p>
<p>Malesuada fames ac turpis egestas sed. Auctor augue mauris augue neque gravida in fermentum et. Risus sed vulputate odio ut enim blandit volutpat maecenas. Interdum consectetur libero id faucibus. Orci ac auctor augue mauris augue neque gravida
in. Sagittis vitae et leo duis ut diam quam nulla. Odio pellentesque diam volutpat commodo sed. In fermentum et sollicitudin ac orci. Sed vulputate odio ut enim blandit volutpat maecenas volutpat blandit. Mi quis hendrerit dolor magna eget est
lorem ipsum. Volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque. Tellus in hac habitasse platea. Vestibulum mattis ullamcorper velit sed ullamcorper morbi. Aliquam eleifend mi in nulla posuere. Diam sollicitudin tempor
id eu nisl nunc. Velit laoreet id donec ultrices tincidunt arcu non sodales neque. Aliquet eget sit amet tellus cras adipiscing enim eu turpis. Hac habitasse platea dictumst vestibulum rhoncus. Eu sem integer vitae justo eget magna fermentum iaculis
eu.
</p>
</div>
</details>
</section>
Do you need this ?
Left and right margin to only p tags
.accordion-button p {
padding: 0 5rem;
}
Delete paddings in details.accordion-button
details.accordion-button {
width: 100%;
margin-bottom: 1rem;
padding-bottom: 0.2rem;
border-radius: var(--buttons-radius);
/* padding-left: 1em;
padding-right: 1em; */
box-sizing: border-box;
}
Add padding in section
section{
padding: 1rem;
}
summary.accordion-button {
display: revert;
}
details.accordion-button {
width: 100%;
margin-bottom: 1rem;
padding-bottom: 0.2rem;
border-radius: var(--buttons-radius);
/* padding-left: 1em;
padding-right: 1em; */
box-sizing: border-box;
}
summary.accordion-button > * {
display: inline;
}
summary.accordion-button:not([open]) {
text-indent: 0.5em;
list-style: revert;
padding: 0.5rem;
background-color: transparent;
border-radius: var(--buttons-radius);
border: var(--buttons-border-width) solid
rgb(var(--color-base-outline-button-labels));
box-shadow: var(--buttons-shadow-horizontal-offset)
var(--buttons-shadow-vertical-offset) var(--buttons-shadow-blur-radius)
rgba(var(--color-shadow), var(--buttons-shadow-opacity));
}
details.accordion-button:not([open]):hover summary {
background: rgb(var(--color-base-text));
color: rgb(var(--color-base-solid-button-labels)); /* marker */
box-shadow: var(--buttons-shadow-horizontal-offset)
var(--buttons-shadow-vertical-offset)
calc(var(--buttons-shadow-blur-radius) * 1.2)
rgba(var(--color-base-accent-1), calc(var(--buttons-shadow-opacity) * 1.25));
}
details.accordion-button:not([open]):hover h4 {
color: rgb(var(--color-base-solid-button-labels));
font-size: 1.2em;
letter-spacing: 0.1em;
}
details.accordion-button[open] {
background: rgba(var(--color-base-text), 0.15);
box-shadow: var(--buttons-shadow-horizontal-offset)
var(--buttons-shadow-vertical-offset) var(--buttons-shadow-blur-radius)
rgba(var(--color-shadow), var(--buttons-shadow-opacity));
}
details.accordion-button[open] h4 {
color: rgb(var(--color-base-solid-button-labels));
font-size: 1.2em;
letter-spacing: 0.1em;
}
details.accordion-button[open] summary {
border-radius: var(--buttons-radius) var(--buttons-radius) 0 0;
background: rgb(var(--color-base-text));
border: none;
letter-spacing: 0.1em;
color: rgb(var(--color-base-solid-button-labels));
box-shadow: none;
}
.accordion-button summary::-webkit-details-marker,
.accordion-button summary::marker {
display: revert;
}
details.accordion-button::-webkit-details-marker:hover,
details summary[open].accordion-button::marker:hover {
color: rgb(var(--color-base-solid-button-labels));
}
/* variables */
:root {
--buttons-radius: 8px;
--buttons-border-width: 2px;
--buttons-border-opacity: 1;
--buttons-shadow-horizontal-offset: 0px;
--buttons-shadow-vertical-offset: 0px;
--buttons-shadow-blur-radius: 0px;
--color-base-text: 68, 34, 115;
--color-base-outline-button-labels: 68, 34, 155;
--color-base-solid-button-labels: 255, 255, 255;
}
/*-------- v2 oddities */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
/*-------- v3 oddities */
summary {
cursor: pointer;
list-style: none;
position: relative;
}
summary .icon-caret {
position: absolute;
height: 0.6rem;
right: 1.5rem;
top: calc(50% - 0.2rem);
}
summary::-webkit-details-marker {
display: none;
}
body,
h1,
h2,
h3,
h4,
h5 {
font-family: sans-serif;
color: #442273;
}
.accordion-button p {
padding: 0 5rem;
}
section{
padding: 1rem;
}
<section>
<h3>Section_Header</h3>
<details class="accordion-button">
<summary class="accordion-button">
<h4>Question_1</h4>
</summary>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Vestibulum
morbi blandit cursus risus. Malesuada fames ac turpis egestas integer
eget. Curabitur gravida arcu ac tortor dignissim convallis aenean et
tortor. Varius vel pharetra vel turpis nunc eget. Velit scelerisque in
dictum non consectetur a erat. Eget duis at tellus at urna. Porttitor
eget dolor morbi non arcu risus quis. Gravida arcu ac tortor dignissim
convallis. Mauris cursus mattis molestie a iaculis. Laoreet non
curabitur gravida arcu. Nunc non blandit massa enim nec dui nunc
mattis enim. Egestas quis ipsum suspendisse ultrices gravida. Sit amet
purus gravida quis blandit turpis. Mauris vitae ultricies leo integer
malesuada nunc vel risus. Risus viverra adipiscing at in. Dictumst
quisque sagittis purus sit amet volutpat consequat mauris nunc. Non
quam lacus suspendisse faucibus interdum. Sed sed risus pretium quam
vulputate dignissim suspendisse in. Sit amet consectetur adipiscing
elit pellentesque habitant.
</p>
<p>
Malesuada fames ac turpis egestas sed. Auctor augue mauris augue neque
gravida in fermentum et. Risus sed vulputate odio ut enim blandit
volutpat maecenas. Interdum consectetur libero id faucibus. Orci ac
auctor augue mauris augue neque gravida in. Sagittis vitae et leo duis
ut diam quam nulla. Odio pellentesque diam volutpat commodo sed. In
fermentum et sollicitudin ac orci. Sed vulputate odio ut enim blandit
volutpat maecenas volutpat blandit. Mi quis hendrerit dolor magna eget
est lorem ipsum. Volutpat commodo sed egestas egestas fringilla
phasellus faucibus scelerisque. Tellus in hac habitasse platea.
Vestibulum mattis ullamcorper velit sed ullamcorper morbi. Aliquam
eleifend mi in nulla posuere. Diam sollicitudin tempor id eu nisl
nunc. Velit laoreet id donec ultrices tincidunt arcu non sodales
neque. Aliquet eget sit amet tellus cras adipiscing enim eu turpis.
Hac habitasse platea dictumst vestibulum rhoncus. Eu sem integer vitae
justo eget magna fermentum iaculis eu.
</p>
</details>
</section>
Related
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.
I made HTML page, with left side navbar(vertical), position fixed , so it will not move when i scroll down the other div(the guide with text),
after that div with text.
I am trying to make it responsive, but since it is fixed position it won't help.
Is there any trick to fix this?
example (not extacly as mine, since its very long code above 200 lines with css and everything)
but still it is the same idea.
notice because the navbar is fixed position it will hide the guide div when screen pixels go down
.sidenav {
height: 100%;
width: 260px;
position: fixed;
z-index: 1;
top: 140px;
left: 135px;
background: #eee;
overflow-x: hidden;
padding: 8px 0;
border-radius: 5px;
}
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 22px;
color: #2b8bc6;
display: block;
}
.sidenav h3 {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 22px;
color: black;
display: block;
}
.box22 {
background-color: #fff;
max-width: 1000px;
margin: auto;
margin-top: 20px;
border-radius: 8px;
}
<body>
<div class="sidenav">
HTML 1 editors
HTML 2 editors
HTML 3 editors
</div>
<div class="box22">
<h1>HTML part 1 intro</h1>
<p>text</p>
</div>
</body>
Use a relative CSS Unit like vw, which is equivalent to 1% of the total viewport.
Right now, you've got it set to an absolute size, 260px. Change that to something like 10vw.
For more info on CSS units, including a list of relative units, check out this W3 page.
.sidenav {
height: 100%;
width: 10vw;
position: fixed;
z-index: 1;
top: 140px;
left: -6px;
background: #eee;
overflow-x: hidden;
padding: 8px 0;
border-radius: 5px;
}
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 22px;
color: #2b8bc6;
display: block;
}
.sidenav h3 {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 22px;
color: black;
display: block;
}
.box22 {
background-color: #fff;
max-width: 1000px;
margin: auto;
margin-top: 20px;
margin-left: 11vw;
border-radius: 8px;
}
<body>
<div class="sidenav">
HTML 1 editors
HTML 2 editors
HTML 3 editors
</div>
<div class="box22">
<h1>HTML part 1 intro</h1>
<p>text</p>
</div>
</body>
Could you do something with a bit of jQuery and more traditional nav layout for smaller responsive designs? Here's an idea: (fiddle: https://jsfiddle.net/moqb29cr/)
HTML:
HTML 1 editors
HTML 2 editors
HTML 3 editors
<h1>HTML part 1 intro</h1>
<div id="responsive_nav">
☰
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu maximus turpis. Cras non leo et felis consectetur tristique. Fusce rutrum erat non facilisis suscipit. Quisque id mi dictum, vestibulum massa sit amet, pharetra justo. Sed rutrum, ligula iaculis mattis sagittis, nisi urna commodo diam, eu auctor mi nunc eu odio. Quisque vel odio viverra, imperdiet augue at, rhoncus orci. Nullam fringilla id tortor vel rutrum. Morbi interdum egestas luctus. Suspendisse nec lacus lacinia, mollis massa auctor, consectetur nisi. Quisque interdum iaculis turpis vitae posuere. Aenean sollicitudin blandit interdum. Nulla vel bibendum nibh, at semper ex.Sed ornare dolor dui, sit amet efficitur lacus varius eget. Nunc ut urna at risus tristique cursus. Nulla rutrum rhoncus odio, vel volutpat nibh hendrerit sed. Nulla tempus id erat nec dictum. Phasellus laoreet pretium posuere. Etiam fringilla ipsum ut porttitor euismod. Mauris auctor nisi vitae sapien lacinia, porta tempor est consequat. Phasellus auctor bibendum varius. Duis convallis justo vitae nibh finibus, et vestibulum enim congue. Sed id nulla quam. Quisque sed cursus eros. Integer ut telVestibulum malesuada elementum diam non tincidunt. Integer et pharetra mi, nec tempus erat. Integer tempor dictum feugiat. Duis vel elit tellus. Etiam ornare consequat accumsan. Fusce sit amet sapien vitae mauris vestibulum mattis a sit amet odio. Maecenas volutpat orci tincidunt ante suscipit eleifend. Sed tempor faucibus ligula, vitae vulputate tortor viverra id. Phasellus ultricies, erat et fermentum tincidunt, augue nisl cursus nulla, id facilisis nunc ante commodo quam.Praesent euismod varius eros non euismod. Fusce posuere nisl lacus, a condimentum nunc efficitur eu. Ut et molestie tortor. Nunc vitae magna at felis rutrum blandit vel ut est. Aenean condimentum ipsum nec lorem condimentum convallis. Donec nec diam vel enim dapibus pretium eu at tortor. Maecenas vulputate sed diam ac aliquam. Aenean pharetra ullamcorper nisi, at egestas justo. Interdum et malesuada fames ac ante ipsum primis in faucibus.Morbi malesuada dui vitae ex pretium, eget congue nisi viverra. Donec hendrerit lorem non augue aliquet dictum. Vivamus molestie in justo in pharetra. Nunc finibus, velit sit amet malesuada bibendum, turpis elit maximus tortor, et vehicula ex tellus non lectus. Donec rhoncus erat placerat, pulvinar est eu, tincidunt neque. Donec ligula enim, bibendum non est non, porta blandit risus. In et facilisis lorem, ut commodo ipsum. Nulla feugiat felis vel rhoncus ultrices. Vivamus vitae orci tincidunt, mattis risus a, mattis dui. Curabitur congue enim at lorem lobortis, nec venenatis leo interdum. Quisque id euismod felis, ut congue nunc.</p>
jQuery:
$("#responsive_nav").click(function(){
$(".sidenav").toggle();
});
And CSS:
p {
position:relative;
display:block;
width:75%;
left:28%;
}
.sidenav {
height: 100%;
width: 25%;
position: fixed;
z-index: 1;
top: 85px;
left;0px;
background: #eee;
overflow-x: hidden;
padding: 8px 0;
border-radius: 5px;
}
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 22px;
color: #2b8bc6;
display: block;
}
.sidenav h3 {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 22px;
color: black;
display: block;
}
.box22 {
background-color: #fff;
max-width: 1000px;
margin: auto;
margin-top: 20px;
border-radius: 8px;
}
#responsive_nav {
display:none;
}
#media only screen and (max-width: 600px) {
.sidenav {
display:none;
}
#responsive_nav {
display:block;
position:fixed;
top:15px;
left:80%;
cursor:pointer;
border-radius:6px;
border:thin solid #ccc;
padding:10px;
}
#responsive_nav:hover {
background-color:#ccc;
border-radius:6px;
padding:10px;
}
p {
width:90%;
left:0%;
}
}
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
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>
Is there a way to prevent a DIV from cutting out from a dynamic filed content? when content is large enough it stays full width and zooms fine but when it's small it breaks off from top group.
Here is a copy of my html & css:
<style>
#title{
font-family: Arial;
font-size: 1.5em;
font-weight: bold;
text-align: center;
background: beige;
padding: 7px 50px 7px 50px;
margin: 10px 0px 0px 0px; /* L&R margins need to be 0px */
}
#box1{ /* Outer Box */
float: left;
font-size: 1em;
text-align: justify;
background: beige;
margin: 0px; /* L&R margins need to be 0px */
padding: 0px 50px 10px 50px;
}
#box2{ /* Inner Box */
font-family: Arial;
float: right;
width: 50%;
font-weight: bold;
font-size: 1em;
text-align: justify;
background: beige;
margin: 0px; /* L&R margins need to be 0px */
padding: 0px 0px 0px 50px;
display: block;
}
#box3{ /* Footnotes */
margin: 0px;
float: left;
font-size: 1em;
text-align: justify;
background: beige;
padding: 0px 50px 30px 50px;
border-radius: 0px 0px 15px 15px;
}
#footnote_columns{
display: block;
overflow:hidden;
/*columns: auto auto; /* column-count: auto column-width: auto; */
column-fill: balance; /* not working!!! */
column-count: 3;
-moz-column-count: 3;
-webkit-column-count: 3;
column-width: auto;
-moz-column-width: auto;
-webkit-column-width: auto;
column-gap: 2em;
-moz-column-gap: 2em;
-webkit-column-gap: 2em;
}
</style>
<!-- ====================== Page Title ===================== -->
<div id='title'>
<HR>
'Title' centered & full width
<HR>
</div>
<!-- ============ text box inside text box ================ -->
<div id="box1"> <!-- Left Side -->
<div id="box2"> <!-- Right Side -->
<p>
INNER Box2 text: " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed nibh eu velit iaculis auctor non ac magna. In at enim quis mi aliquam vestibulum imperdiet eu magna. Ut aliquet arcu at felis dapibus euismod. Suspendisse dolor turpis, faucibus quis mollis vitae, iaculis vel urna. Integer sit amet dui malesuada justo facilisis rutrum sed vel neque. Cras condimentum est sit amet mi dapibus convallis. Donec molestie euismod velit id pharetra. Praesent sit amet eros at quam ullamcorper sodales. Aenean ligula dui, ultricies quis commodo ut, lobortis eu justo. Nulla dolor augue, vulputate at placerat in, ornare et purus. "
</p>
<HR>
</div>
<p>
OUTER Box1 text: " Etiam at pretium urna. Morbi condimentum consequat nisi, nec pulvinar tellus fermentum at. Cras ut sodales ante. Sed feugiat sem eget eros lobortis sit amet porttitor mauris tempus. Sed eros est, placerat at sollicitudin quis, scelerisque ac dolor. Proin mollis euismod condimentum. Morbi eget tortor justo, eu vestibulum orci. Pellentesque eu ante a nunc adipiscing sodales dictum vitae eros. Sed tellus mauris, volutpat non vulputate ut, vulputate ut orci. Vivamus facilisis ipsum a tellus gravida pellentesque. Nam risus magna, eleifend dignissim porttitor et, sagittis quis nisl.
Sed eget lorem magna. Sed sed imperdiet elit. Sed vulputate dapibus tellus, nec scelerisque risus hendrerit quis. Fusce aliquet erat non nibh egestas posuere. Aliquam ipsum velit, venenatis vel dictum ac, luctus nec sapien. In hac habitasse platea dictumst. Vivamus a elit augue. Integer pellentesque enim sit amet sem condimentum ut tincidunt nunc mollis. Cras in tellus eget dui pellentesque adipiscing. In varius ullamcorper felis, vitae sagittis turpis rutrum in. Aliquam consectetur consectetur erat, quis tristique magna laoreet id. Etiam orci arcu, ultricies eget interdum non, mollis quis est. Mauris odio lacus, tempus at porta quis, laoreet porta tortor. "
<HR>
</div>
<div id='box3'>
<div id='footnote_columns'>
<p>
FOOTNOTE Box3 text: " Vivamus egestas tempor molestie. Morbi scelerisque nunc non eros ultrices volutpat. Suspendisse potenti. Sed lobortis, odio vitae pharetra dapibus, risus turpis scelerisque risus, a dapibus dui ante sed ante. "
</p>
</div>
<HR>
</div>
<!-- ======================================================= -->
Example 1 works - has plenty of txt -
Example 2 breaks - when you zooming -
(1) http://jsfiddle.net/NuxWD/1/ - full text
(2) http://jsfiddle.net/NuxWD/2/ - try zooming, notice footnote
(3) http://jsfiddle.net/NuxWD/3/ - small amount of txt in footnote
(4) http://jsfiddle.net/NuxWD/4/ (5) http://jsfiddle.net/NuxWD/5/ - everything breaks!
Need this for dynamic content. If I remove the BR in example (4) the frame stays fine;
How can frame remain in full width even when paragraphs are short?
Notice bottom row, the Footnote, try adjusting amount of txt; or zoom out
IE does not even column footnote at all.
Why is the title not affected at all whether have smalls amount of txt or you zoom out ?