Putting animated text in the background with CSS? - html

I've found other examples of text in the background but not animated. I want it to be positioned like this.
Here's what I'm working with. https://jsfiddle.net/3esj55rb
.marquee {
color: #333;
padding-left: 1.5em;
position: relative;
font: 50px 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
width: 450px;
margin: 2em auto
overflow: hidden;
white-space: nowrap;
box-sizing: border-box;
animation: marquee 25s linear infinite;
}
.marquee:hover {
color: #F65314;
animation-play-state: paused
}
#keyframes marquee {
0% {
text-indent: 27.5em
}
100% {
text-indent: -105em
}
}
/* Make it pretty */
.microsoft {
padding-left: 1.5em;
position: relative;
font: 50px 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
}
/* ::before was :before before ::before was ::before - kthx */
.microsoft:before,
.microsoft::before {
z-index: 2;
content: '';
position: absolute;
top: -1em;
left: -1em;
width: .5em;
height: .5em;
box-shadow: 1.0em 1.25em 0 #F65314, 1.6em 1.25em 0 #7CBB00, 1.0em 1.85em 0 #00A1F1, 1.6em 1.85em 0 #FFBB00;
}
.microsoft:after,
.microsoft::after {
z-index: 1;
content: '';
position: absolute;
top: 0;
left: 0;
width: 2em;
height: 2em;
background-image: linear-gradient(90deg, white 70%, rgba(255, 255, 255, 0));
}
/* Style the links */
.vanity {
color: #333;
text-align: left;
font: 20px 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
}
.vanity a,
.microsoft a {
color: #1570A6;
transition: color .5s;
text-decoration: none;
}
.vanity a:hover,
.microsoft a:hover {
color: #F65314;
}
.text {
color: #333;
text-align: left;
font: 20px 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
}
.topText {
color: #333;
text-align: left;
font: 20px 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
margin-top: 70px;
}
<p class="topText">
Boston, city, capital of the commonwealth of Massachusetts,
and seat of Suffolk county, in the northeastern United States.
It lies on Massachusetts Bay, an arm of the Atlantic Ocean.
The city proper has an unusually small area for a major city,
and more than one-fourth of the total—including part of the
Charles River, Boston Harbor, and a portion of the Atlantic—is water.
Area city, 46 square miles (119 square km).
</p>
<p class="marquee"> Visit Boston. This text should be in the background</p>
<p class="text">
The area, the people, and the institutions within its political
boundaries can only begin to define the essence of Boston. Its
nickname “Beantown” has its origin in colonial times, when Boston,
as a stop on a major trade route with the West Indies, had a steady
supply of molasses from the Caribbean, thus leading to the creation
of a popular dish that became known as Boston baked beans (beans
baked in molasses).
</p>
<p class="vanity">
Follow us on twitter
#boston to know more.
</p>
<p class="vanity">
Test test
click here for website or our state's mass.gov
</p>

Added z index and made position relative to the container.
.marquee {
color: #333;
padding-left: 1.5em;
font: 50px 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
margin: 2em auto
overflow: hidden;
white-space: nowrap;
box-sizing: border-box;
animation: marquee 10s linear infinite;
z-index: -1;
position: fixed;
width: 450px;
top: 15%;
}

With the use of CSS you can define #keyframes so that you can create different positions, sizes, angels and properties of an object.
for your reference:
#keyframes example {
0% {background-color: red;}
25% {background-color: yellow;}
50% {background-color: blue;}
100% {background-color: green;}
}
Here you can find the resources:https://css-tricks.com/css-techniques-and-effects-for-knockout-text/

Short answer
You have to play with position (relative / absolute along with top). Beware of children ordering. Also, when you need to stop the animation when hovering, make sure you are putting the :hover listener to the proper tag.
Long answer
For the sake of playing with position, I came up with a solution. However, this solution requires text duplication.
The idea is as follows:
A container will contain three children
The first child is the first text. It is invisible and its purpose is to fix the container height
The second child is the sliding text. With a position: absolute, it has to vertically align its content via a subcontainer.
The third child is the displayed text with an absolute position as well
I expanded the original text to ensure that my marquee is properly vertically aligned.
Cons
Text is displayed twice
a lot of CSS classes & container but it is always like this, isn't it?
Pros
You can put whatever you want in the .marquee__content, not only a p but also some h2 or h3 or some picture, it should all slide. the .marquee *{...} style ensure that all children do not wrap text
CSS clearer separation: which div is what
Finally the code:
/* ========== Container ========== */
/* cosmetic only */
body {
background-color: #cacaca;
}
.container {
/* Required for playing with positions ! */
position: relative;
/* irrelevant: cosmetic only */
width: 60%;
margin: auto;
background: white;
}
/* ========== Text =============== */
/* define all text size so that height fixer can
have the appropriate height */
.text {
/* to ensure both box__text have same height */
font-size: 20px;
/* cosmetic only */
padding: 1rem;
box-sizing: border-box;
}
/* this hack requires an invisible box__text to set
parent div height */
.text--height-fixer {
visibility: hidden;
}
.text--shown {
position: absolute;
/* move to top of parent */
top: 0;
/* take parent width / height */
width: 100%;
height: 100%;
}
/* ========== Marquee ============ */
.marquee {
position: absolute;
/* move to top of parent */
top: 0;
/* take parent width / height */
width: 100%;
height: 100%;
/* hide x overflow for the slide effect */
overflow-x: hidden;
/* vertically align content. I chose display: flex as
I am lazy but this is not the core of the question */
display: flex;
/* cosmetic only */
padding: 1rem;
box-sizing: border-box;
opacity: 0.6;
}
/* force one line layout for all children, not only <p> */
.marquee * {
/* remove line break */
white-space: nowrap;
/* remove all default margin */
margin: auto;
}
/* to match the provided picture */
.marquee .boston {
color: lightblue;
font-size: 4rem;
font-weight: 800;
transition: color 0.2s;
}
#keyframes marquee {
0% {
margin-left: 100%;
}
100% {
margin-left: -100%;
}
}
.marquee__content {
animation: marquee 10s linear infinite;
}
/* this is the tricky part: the "hover" event should not be listened
on marquee but on the container */
.container:hover .marquee__content {
animation-play-state: paused;
}
.container:hover .marquee .boston {
color: orange;
}
<!-- container to manage all positions. Children order matters !-->
<div class="container">
<!-- relative must be first -->
<div class="text text--height-fixer">
<p>
The area, the people, and the institutions within its political boundaries can only begin to define the essence of Boston. Its nickname “Beantown” has its origin in colonial times, when Boston, as a stop on a major trade route with the West Indies, had
a steady supply of molasses from the Caribbean, thus leading to the creation of a popular dish that became known as Boston baked beans (beans baked in molasses). The area, the people, and the institutions within its political boundaries can only
begin to define the essence of Boston. Its nickname “Beantown” has its origin in colonial times, when Boston, as a stop on a major trade route with the West Indies, had a steady supply of molasses from the Caribbean, thus leading to the creation
of a popular dish that became known as Boston baked beans (beans baked in molasses).
</p>
</div>
<!-- marquee should be declared before text so that it appears below without z-index -->
<div class="marquee">
<div class="marquee__content">
<p class="boston">
Visit Boston. This text should be in the background
</p>
</div>
</div>
<div class="text text--shown">
<p>
The area, the people, and the institutions within its political boundaries can only begin to define the essence of Boston. Its nickname “Beantown” has its origin in colonial times, when Boston, as a stop on a major trade route with the West Indies, had
a steady supply of molasses from the Caribbean, thus leading to the creation of a popular dish that became known as Boston baked beans (beans baked in molasses). The area, the people, and the institutions within its political boundaries can only
begin to define the essence of Boston. Its nickname “Beantown” has its origin in colonial times, when Boston, as a stop on a major trade route with the West Indies, had a steady supply of molasses from the Caribbean, thus leading to the creation
of a popular dish that became known as Boston baked beans (beans baked in molasses).
</p>
</div>
</div>
If anyone has a better solution which allows any marquee content (not limited to a single p), feel free to share!

Related

How to make element appear on hover text?

So I have this text that I want to have a link appear over. For example here is an image of what I want to appear :
When I hover on the highlighted text or when I hover on the link I want it to appear but I'm not sure how to go about this. For example I tried something similar but I can't seem to have the hover text seemlessly go with other text :
<p class="text">Espresso is coffee brewed by expressing or forcing a small amount of nearly boiling water under pressure through finely ground coffee beans.<span class="span"> Espresso is generally thicker than coffee brewed by other methods, has a higher concentration of suspended and dissolved solids, and has crema on top (a foam with a creamy consistency). <span class="hide" id="hide">Hello</span></span> As a result of the pressurized brewing process, the flavors and chemicals in a typical cup of espresso are very concentrated. Espresso is also the base for other drinks such as a caffè latte, cappuccino, caffè macchiato, caffè mocha, flat white, or caffè Americano. Espresso has more caffeine per unit volume than most coffee beverages, but because the usual serving size is much smaller, the total caffeine content is less than a mug of standard brewed coffee, contrary to a common belief.[2] Although the actual caffeine content of any coffee drink varies by size, bean origin, roast method and other factors, the caffeine content of typical servings of espresso vs. drip brew are 120 to 170 mg[3] vs. 150 to 200 mg.[4][5]</p>
And here is the css :
.span {
background-color: rgba(255, 16, 16, 0.25);
text-decoration: underline;
text-decoration-style: solid;
text-decoration-color: black;
}
.hide {
position: absolute;
display: none;
background-color: #2B2424;
color: #339CD8;
line-height: 18px;
font-size: 18px;
padding:10px;
}
.span:hover > .hide {
position: absolute;
display: block;
}
Now this only makes the item appear when the text is hovered over it, but I want the bubble to always appear in the same place relative to the text. Now this works if I switch the span tags with p tags. But If I do that, the text won't stick with all the other text around it. It does this:
Now I'm not sure what to do. Thanks in advance!! (Also I hate css so much)
i am sorry before, i want to help but 50%. I just give you some example about the dialog. sorry i cannot helpfully
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Popup container - can be anything you want */
.popup {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* The actual popup */
.popup .popuptext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px;
}
/* Popup arrow */
.popup .popuptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
/* Toggle this class - hide and show the popup */
.popup .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s;
}
/* Add animation (fade in the popup) */
#-webkit-keyframes fadeIn {
from {opacity: 0;}
to {opacity: 1;}
}
#keyframes fadeIn {
from {opacity: 0;}
to {opacity:1 ;}
}
</style>
</head>
<body style="text-align:center">
<h2>Popup</h2>
<div class="popup" onclick="myFunction()">Click me to toggle the popup!
<span class="popuptext" id="myPopup">A Simple Popup!</span>
</div>
<script>
// When the user clicks on div, open the popup
function myFunction() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
}
</script>
</body>
</html>

What causes the scrollbar to go behind fixed div

I have a fixed navigation menu at the top of my webpage and another one on the right side of the webpage. However my top (fixed) navigation menu causes the scrollbar to go behind the navigation menu div. I have tried searching for solutions and found that I should delete overflow: auto in my html, body selectors. However if I do that, then the navigation menu on the right side doesn't extend to the full height of the document (100%). How can I fix this?
html,
body {
height: 100%;
background-color: white;
margin: 0px;
padding: 0px;
font-family: "Gill Sans", sans-serif;
overflow: auto;
z-index: 50;
}
body {
min-height: 100%;
}
.navigation-menu {
position: fixed;
top: 0px;
width: 100%;
background-color: black;
z-index: 60;
}
.menu {
position: relative;
top: 0px;
list-style: none;
padding: 0px;
margin: 0px;
background-color: #6157CC;
}
.navigation-menu a {
float: left;
padding: 15px 20px;
color: white;
text-decoration: none;
}
h1 {
color: #6157CC;
text-align: center;
position: relative;
top: 90px;
z-index: 1;
margin: 0px 0px 0px 170px;
}
.contents {
float: left;
position: absolute;
width: 15%;
height: 100%;
background-color: red;
z-index: 5;
display: block;
overflow: auto;
}
#plants {
list-style: none;
position: absolute;
top: 3%;
text-align: center;
}
#plants a {
position: relative;
display: block;
padding: 25px 10px;
top: 20px;
color: white;
text-decoration: none;
}
.plants-definition {
position: relative;
float: right;
width: 85%;
top: 80px;
left: 0px;
}
p {
margin: 20px 50px;
}
h2 {
padding: 55px 0px 0px 0px;
margin: 0px 50px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="Nature.CSS">
<meta charset="UTF-8">
<title>Nature</title>
</head>
<body>
<div class="navigation-menu">
<nav>
<ul class="menu">
<li><a>Home</a></li>
<li><a>Plants</a></li>
<li><a>Animals</a></li>
<li><a>Oceans</a></li>
</ul>
</nav>
</div>
<div class="contents">
<ul id="plants">
<li><a>Trees</a></li>
<li><a>Flowers</a></li>
<li><a>Water Plants</a></li>
</ul>
</div>
<div>
<h1>Plants</h1>
</div>
<div class="plants-definition">
<h2>Trees</h2>
<p>In botany, a tree is a perennial plant with an elongated stem, or trunk, supporting branches and leaves in most species. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are usable
as lumber or plants above a specified height. Trees are not a taxonomic group but include a variety of plant species that have independently evolved a woody trunk and branches as a way to tower above other plants to compete for sunlight. Trees tend
to be long-lived, some reaching several thousand years old. In wider definitions, the taller palms, tree ferns, bananas, and bamboos are also trees. Trees have been in existence for 370 million years. It is estimated that there are just over 3 trillion
mature trees in the world</p>
</div>
<div>
<h2>Flowers</h2>
<p></p>
</div>
<div class="plants-definition">
<h2>Flowers</h2>
<p>A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to effect reproduction, usually by providing
a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) or allow selfing (fusion of sperm and egg from the same flower). Some flowers produce diaspores
without fertilization (parthenocarpy). Flowers contain sporangia and are the site where gametophytes develop. Many flowers have evolved to be attractive to animals, so as to cause them to be vectors for the transfer of pollen. After fertilization,
the ovary of the flower develops into fruit containing seeds.</p>
</div>
<div class="plants-definition">
<h2>Water Plants</h2>
<p>Aquatic plants are plants that have adapted to living in aquatic environments (saltwater or freshwater). They are also referred to as hydrophytes or macrophytes. A macrophyte is an aquatic plant that grows in or near water and is either emergent,
submergent, or floating, and includes helophytes (a plant that grows in marsh, partly submerged in water, so that it regrows from buds below the water surface).[1] In lakes and rivers macrophytes provide cover for fish and substrate for aquatic
invertebrates, produce oxygen, and act as food for some fish and wildlife.</p>
</div>
</body>
</html>
https://jsfiddle.net/e679hmx4/2/
(I know it doesn't look pretty at all now, but I think you should be able to understand the general idea).
Your issue is because of overflow: auto on your html, body. If you remove this your scrollbar will appear as expected:
html, body {
height: 100%;
background-color: white;
margin: 0px;
padding: 0px;
font-family: "Gill Sans", sans-serif;
overflow: auto;
z-index: 50;
}
Once you've done this, you'll also need to set your side navbar (.content) to position: fixed such that it fills the correct height.
See example below:
html,
body {
height: 100%;
background-color: white;
margin: 0px;
padding: 0px;
font-family: "Gill Sans", sans-serif;
z-index: 50;
}
body {
min-height: 100%;
}
.navigation-menu {
position: fixed;
top: 0px;
width: 100%;
background-color: black;
z-index: 60;
}
.menu {
position: relative;
top: 0px;
list-style: none;
padding: 0px;
margin: 0px;
background-color: #6157CC;
}
.navigation-menu a {
float: left;
padding: 15px 20px;
color: white;
text-decoration: none;
}
h1 {
color: #6157CC;
text-align: center;
position: relative;
top: 90px;
z-index: 1;
margin: 0px 0px 0px 170px;
}
.contents {
float: left;
position: fixed;
/* change position to fixed */
width: 15%;
height: 100%;
background-color: red;
z-index: 5;
display: block;
overflow: auto;
}
#plants {
list-style: none;
position: absolute;
top: 3%;
text-align: center;
}
#plants a {
position: relative;
display: block;
padding: 25px 10px;
top: 20px;
color: white;
text-decoration: none;
}
.plants-definition {
position: relative;
float: right;
width: 85%;
top: 80px;
left: 0px;
}
p {
margin: 20px 50px;
}
h2 {
padding: 55px 0px 0px 0px;
margin: 0px 50px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="Nature.CSS">
<meta charset="UTF-8">
<title>Nature</title>
</head>
<body>
<div class="navigation-menu">
<nav>
<ul class="menu">
<li><a>Home</a></li>
<li><a>Plants</a></li>
<li><a>Animals</a></li>
<li><a>Oceans</a></li>
</ul>
</nav>
</div>
<div class="contents">
<ul id="plants">
<li><a>Trees</a></li>
<li><a>Flowers</a></li>
<li><a>Water Plants</a></li>
</ul>
</div>
<div>
<h1>Plants</h1>
</div>
<div class="plants-definition">
<h2>Trees</h2>
<p>In botany, a tree is a perennial plant with an elongated stem, or trunk, supporting branches and leaves in most species. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are usable
as lumber or plants above a specified height. Trees are not a taxonomic group but include a variety of plant species that have independently evolved a woody trunk and branches as a way to tower above other plants to compete for sunlight. Trees tend
to be long-lived, some reaching several thousand years old. In wider definitions, the taller palms, tree ferns, bananas, and bamboos are also trees. Trees have been in existence for 370 million years. It is estimated that there are just over 3 trillion
mature trees in the world</p>
</div>
<div>
<h2>Flowers</h2>
<p></p>
</div>
<div class="plants-definition">
<h2>Flowers</h2>
<p>A flower, sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants (plants of the division Magnoliophyta, also called angiosperms). The biological function of a flower is to effect reproduction, usually by providing
a mechanism for the union of sperm with eggs. Flowers may facilitate outcrossing (fusion of sperm and eggs from different individuals in a population) or allow selfing (fusion of sperm and egg from the same flower). Some flowers produce diaspores
without fertilization (parthenocarpy). Flowers contain sporangia and are the site where gametophytes develop. Many flowers have evolved to be attractive to animals, so as to cause them to be vectors for the transfer of pollen. After fertilization,
the ovary of the flower develops into fruit containing seeds.</p>
</div>
<div class="plants-definition">
<h2>Water Plants</h2>
<p>Aquatic plants are plants that have adapted to living in aquatic environments (saltwater or freshwater). They are also referred to as hydrophytes or macrophytes. A macrophyte is an aquatic plant that grows in or near water and is either emergent,
submergent, or floating, and includes helophytes (a plant that grows in marsh, partly submerged in water, so that it regrows from buds below the water surface).[1] In lakes and rivers macrophytes provide cover for fish and substrate for aquatic
invertebrates, produce oxygen, and act as food for some fish and wildlife.</p>
</div>
</body>
</html>
Removing overflow: auto; on html, body will stop this from happening, also I would avoid adding z-index to body and html tags.

HTML/CSS - Increased Font-Size Shifts Everything on Page to Left

I'm building a site as a learning exercise. It's aim is to showcase some stories, so the readability of the text is quite important.
For the Home, About and similar pages, the layout I have is fine. However, on the pages with a story on, after I increase the font-size to 1.2rem or above, the paragraphs seem to move everything on the page to the left relative to the position of everything on the other pages.
I've set the widths for all of the containers but it doesn't seem to be making a difference.
I've tried isolating the problem and only the font size makes any difference. If I set it lower than 1.2rem it shifts back to its correct position.
The HTML for one of the story pages and the story pages CSS file are below. Any bootstrap terms are just terms I've adopted, they're not using any Bootstrap styling. Trying to build this from the ground up.
Apologies if this is obvious or any of the below is badly formatted / badly written.
Appreciate any help.
Thank you!
/* Fonts */
/* Montserrat and Raleway */
#import url('https://fonts.googleapis.com/css?family=Montserrat|Raleway');
/* Reset */
* {
box-sizing: border-box;
}
html {
font-size: 16px;
font-family: 'Raleway', sans-serif;
}
/* Components */
.container {
width: 66%;
margin: 0 auto;
}
.jumbotron {
background-color: #ededed;
padding: 6% 10%;
margin: 20px;
}
.jumbotron-header {
font-size: 2rem;
font-family: 'Montserrat', sans-serif;
}
/*block size and height, margins left and right slightly*/
.story-text {
font-size: 1.5rem;
line-height: 1.5;
margin: 20px;
width: 100%;
}
.story-text > p {
width: 100%;
}
.story-subtitle {
font-size: 2rem;
font-weight: 600;
font-family: 'Montserrat', sans-serif;
}
.quote-block {
margin: 50px 300px;
}
.quote {
font-style: italic;
}
.quote-attribution {
font-weight: 700;
}
/* General Styling */
a {
text-decoration: none;
color: black;
}
/* Navigation */
/* Layout */
.nav-area {
display:flex;
height: 40px;
background-color: #ededed;
align-items: center;
}
.nav-links {
display: flex;
flex-grow: 10;
align-items: center;
}
.logo-area {
display: flex;
flex-grow: 1;
justify-content: space-around;
align-items: center;
background-color: #bcbcbc;
height: inherit;
}
/* Styling */
#logo {
font-size: 20px;
font-weight: bold;
}
.nav-links > div {
height: 40px;
line-height: 40px;
}
.nav-links span {
font-size: 20px;
margin: 20px;
line-height: normal;
vertical-align: middle;
}
.nav-links > div:hover {
background-color: #ffffff;
}
/* Mobile */
/* Burger Menu */
.mobile-nav {
display: none;
}
.mobile-menu {
display: none;
}
.mobile-menu > div {
background-color: #ededed;
border: 1px solid #e5e5e5;
padding: 5%;
}
.mobile-menu > div:hover {
background-color: #cecece;
}
/* Navigation */
#media screen and (max-width: 826px) {
.nav-area {
height: auto;
}
.logo-area {
padding: 5%;
}
}
#media screen and (max-width: 700px) {
.nav-links {
display: none;
}
.mobile-nav {
display: block;
margin: 20px;
}
}
#media screen and (max-width: 740px) {
.jumbotron-header {
font-size: 1rem;
}
.story-text {
font-size: 1rem;
}
.story-subtitle {
font-size: 1.2rem;
}
}
<body>
<!-- Navbar -->
<header>
<div class="nav-area container">
<div class="logo-area">
<span id="logo">The Lovecraft Project</span>
</div>
<div class="nav-links">
<div><span>Home</span></div>
<div><span>About</span></div>
<div><span>Stories</span></div>
</div>
<!-- Burger Menu -->
<i class="mobile-nav fas fa-bars"></i>
</div>
</header>
<div class="container">
<!-- Mobile Menu -->
<div class="mobile-menu">
<div>Home</div>
<div>About</div>
<div>Stories</div>
</div>
</div>
<!-- Content -->
<div class="container">
<div class="jumbotron">
<div class="jumbotron-header">
<h1>The Shadow Over Innsmouth</h1>
<hr>
<p>H.P. Lovecraft</p>
</div>
</div>
<div class="story-text">
<p class="story-subtitle">I.</p>
<p>During the winter of 1927–28 officials of the Federal government made a strange and secret investigation of certain conditions in the ancient Massachusetts seaport of Innsmouth. The public first learned of it in February, when a vast series of raids and arrests occurred, followed by the deliberate burning and dynamiting—under suitable precautions—of an enormous number of crumbling, worm-eaten, and supposedly empty houses along the abandoned waterfront. Uninquiring souls let this occurrence pass as one of the major clashes in a spasmodic war on liquor.</p>
<p>Keener news-followers, however, wondered at the prodigious number of arrests, the abnormally large force of men used in making them, and the secrecy surrounding the disposal of the prisoners. No trials, or even definite charges, were reported; nor were any of the captives seen thereafter in the regular gaols of the nation. There were vague statements about disease and concentration camps, and later about dispersal in various naval and military prisons, but nothing positive ever developed. Innsmouth itself was left almost depopulated, and is even now only beginning to shew signs of a sluggishly revived existence.</p>
<p>Complaints from many liberal organisations were met with long confidential discussions, and representatives were taken on trips to certain camps and prisons. As a result, these societies became surprisingly passive and reticent. Newspaper men were harder to manage, but seemed largely to coöperate with the government in the end. Only one paper—a tabloid always discounted because of its wild policy—mentioned the deep-diving submarine that discharged torpedoes downward in the marine abyss just beyond Devil Reef. That item, gathered by chance in a haunt of sailors, seemed indeed rather far-fetched; since the low, black reef lies a full mile and a half out from Innsmouth Harbour.</p>
<p>People around the country and in the nearby towns muttered a great deal among themselves, but said very little to the outer world. They had talked about dying and half-deserted Innsmouth for nearly a century, and nothing new could be wilder or more hideous than what they had whispered and hinted years before. Many things had taught them secretiveness, and there was now no need to exert pressure on them. Besides, they really knew very little; for wide salt marshes, desolate and unpeopled, keep neighbours off from Innsmouth on the landward side.</p>
<p>But at last I am going to defy the ban on speech about this thing. Results, I am certain, are so thorough that no public harm save a shock of repulsion could ever accrue from a hinting of what was found by those horrified raiders at Innsmouth. Besides, what was found might possibly have more than one explanation. I do not know just how much of the whole tale has been told even to me, and I have many reasons for not wishing to probe deeper. For my contact with this affair has been closer than that of any other layman, and I have carried away impressions which are yet to drive me to drastic measures.</p>
</div>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script type="text/javascript" src="../Resources/Scripts/script.js"></script>
</body>
I guess the problem is, whenever you are increasing the font-size it is aligning itself accordingly inside the fixed width that you have provided. So, in order to get the desired layout every time use percentages rather than fixed values.

Floating to the right

I am designing a website using HTML and CSS and there appears to be an invisible margin somewhere.
Currently, my website looks like this:
h1, h2 {
font-family: 'Righteous', cursive;
text-align: center;
}
body {
font-family: 'Roboto', sans-serif;
color: black;
border: 5px solid #375E97;
}
article, aside {
padding: 1%;
margin: 1.5% 0;
border: 5px solid #375E97;
border-left: 0;
display: inline-block;
vertical-align: top;
}
article {
width: 60%;
}
aside {
width: 30%;
background-image: url("money-stack.png");
background-size: cover;
background-position: 200px 200px;
}
h1 {
background-color: #375E97;
color: #FFFFFF;
font-size: 6.9vw;
text-transform: uppercase;
padding: 0;
margin: 0 auto 2.1% auto;
line-height: 4.9vw;
height: 5vw;
}
h2 {
color: #375E97;
font-size: 3.5vw;
padding: 0;
margin: 0;
}
p {
padding: 0;
margin: 1% 0 0 0;
font-size: 1vw;
}
.sub-heading {
font-style: italic;
text-align: center;
}
.sub-heading > span {
font-weight: 700;
font-style: normal;
}
<!DOCTYPE html>
<html>
<head>
<title>Act 1</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Righteous|Roboto:400,700,400i" rel="stylesheet">
</head>
<body>
<header>
<h1>Filler text here</h1>
</header>
<article>
<h2>More more</h2>
<p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.</p>
<p>Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean.</p>
<p>A small river named Duden flows by their place and supplies it with the necessary regelialia.</p>
<p>It is a paradisematic country, in which roasted parts of sentences fly into your mouth.</p>
<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.</p>
</article>
<aside>
<h2>And More</h2>
<p>
<div class="sub-heading">
<p>She packed her seven versalia, put her initial into the belt and made herself on the way.</p>
</div>
<br>
<p>The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen.</p>
</p>
</aside>
</body>
</html>
If you look closely at the article and aside in the middle of the screenshot, you can see that I have made their display: inline-block; and removed the border from the left of the aside (smaller one).
The Problem
The problem is that I want to actually "pin" the aside to the right of the body, not the article. I know that to make this work I would have to remove the border from the right and add it to the left.
What I Have Tried
Playing around with various values for align, text-align and all the other aligns you can think of.
Making the aside and article have no tags in between them.
Please note, I have seen other solutions for this, but I want a clean solution that makes sense.
This is what you were trying to achieve I guess.
article and aside are now floated left and right.
This is actually the solution from kukkuz in the comments. I don't know why it shouldn't work for you.
A clearfix is used instead of an additional element with clear: both
Without the surrounding element, body in this case, doesn't get the height from its content and the border around everything wouldn't display correctly.
h1, h2 {
font-family: 'Righteous', cursive;
text-align: center;
}
body {
font-family: 'Roboto', sans-serif;
color: black;
border: 5px solid #375E97;
}
body:after {
content: '';
clear: both;
display: table;
}
article, aside {
padding: 1%;
margin: 1.5% 0;
border: 5px solid #375E97;
border-left: 0;
}
article {
width: 60%;
float: left;
}
aside {
width: 30%;
border-left: 5px solid #375E97;
border-right: 0;
float: right;
background-image: url("money-stack.png");
background-size: cover;
background-position: 200px 200px;
}
h1 {
background-color: #375E97;
color: #FFFFFF;
font-size: 6.9vw;
text-transform: uppercase;
padding: 0;
margin: 0 auto 2.1% auto;
line-height: 4.9vw;
height: 5vw;
}
h2 {
color: #375E97;
font-size: 3.5vw;
padding: 0;
margin: 0;
}
p {
padding: 0;
margin: 1% 0 0 0;
font-size: 1vw;
}
.sub-heading {
font-style: italic;
text-align: center;
}
.sub-heading > span {
font-weight: 700;
font-style: normal;
}
<!DOCTYPE html>
<html>
<head>
<title>Act 1</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Righteous|Roboto:400,700,400i" rel="stylesheet">
</head>
<body>
<header>
<h1>Filler text here</h1>
</header>
<article>
<h2>More more</h2>
<p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts.</p>
<p>Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean.</p>
<p>A small river named Duden flows by their place and supplies it with the necessary regelialia.</p>
<p>It is a paradisematic country, in which roasted parts of sentences fly into your mouth.</p>
<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.</p>
</article>
<aside>
<h2>And More</h2>
<p>
<div class="sub-heading">
<p>She packed her seven versalia, put her initial into the belt and made herself on the way.</p>
</div>
<br>
<p>The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen.</p>
</p>
</aside>
</body>
</html>
I hope I understood your issue. There's many ways you could achieve this, the most obvious one would be to remove your inline rule and make both aside and article float: right; and float: left; respectively, but float was intended to make text float around images and not exactly to position divs (eventhough it works). As so, what I would try is to position: absolute; both the aside and article; and use left, right, top, bottom to position elements.
article {
position: absolute;
top: 69px;
width: 60%;
}
aside {
background-image: url("money-stack.png");
background-position: 200px 200px;
background-size: cover;
position: absolute;
right: 8px;
top: 69px;
width: 30%;
}
body {
border: 5px solid #375e97;
color: black;
font-family: "Roboto",sans-serif;
min-height: 318px;
}
After, you can either set a minimum size for the container, or add a clear:both; styled element to the bottom in order to make the container stretch to the correct size.
One other thing I think you should change is the fact that you're using body as your container and applying styles to it. I think it's good practice to create an actual container div, and apply styles to that instead.

Text block over image

I have used the following tutorial to make a text block over an image: http://css-tricks.com/text-blocks-over-image/. I found it really easy actually, and quite useful, but there is one thing I could never work with, and these are span tags.
The issue I'm having is that I want to format the second part of the text in the span to have a lower font size and have a left padding. I've tried including a second span and defining it in the css file, but it doesn't really do anything, just stays where it is. I also tried extending the block until the end of the picture, but a width of 1000px on each wouldn't work.
Here's some pictures, as they speak a thousand words...
How it looks on mine...
And how I want it to look...
And here's some code...
<div class="img_destination">
<img src="<?php echo SITE_URL?>/lib/skins/gsm/images/featured_destination/gcfv.png" alt="" />
<h2 id="featured_destination"><span>>> Explore Fuerteventura<span class='spacer'></span><span class='spacer'></span>The island of natural beauty</span></h2>
</div>
CSS...
/* Featured Destination */
.img_destination {
position: relative;
width: 100%; /* for IE 6 */
}
h2#featured_destination {
position: absolute;
top: 355px;
left: 0;
width: 100%;
}
h2#featured_destination span {
color: white;
font: bold 28px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgba(00, 36, 63, 0.7);
padding: 10px;
}
h2#featured_destination span.spacer {
padding:0 5px;
background: none;
}
Here is what you posted:
<h2 id="featured_destination"><span>>> Explore Fuerteventura<span class='spacer'></span><span class='spacer'></span>The island of natural beauty</span></h2>
I would suggest a couple different things. Firstly, instead if using >> for those arrows, use the >>. Sometimes extra symbols get rendered incorrectly by the browser, so it is always safest to encode them when you want the display to be literal. Also, I would not use an empty span tag to create whitespace since it tends to clutter up the markup.
But your primary issue is that you need to change the way your span tags are nested to NOT include the ">>Explore Fuerteventura" inside any span tags so that the two sections of text are styled differently. I think your aims can be achieved by simply cleaning up your markup to something more like this:
<h2 id="featured_destination">>> Explore Fuerteventura <span class='spacer'> The island of natural beauty</span></h2>
Is this the effect you're after: jsFiddle example.
I changed the text div to:
<h2 id="featured_destination">
<span class="bold">>> Explore Fuerteventura</span><span class='spacer'></span><span class='spacer'></span>The island of natural beauty
</h2>
I wrapped the first chunk of text in its own span so you can style it with a bold font face while the rest of the text has a normal weight.
And this is the CSS I modified:
/* Featured Destination */
.img_destination {
position: relative;
width: 100%;
/* for IE 6 */
}
h2#featured_destination {
position: absolute;
top: 355px;
left: 0;
width: 100%;
background: rgba(00,36,63,0.7);
font: 28px/45px Helvetica, Sans-Serif;
color: #FFF;
letter-spacing: -1px;
}
h2#featured_destination span {
padding: 10px;
}
h2#featured_destination span.spacer {
padding: 0 5px;
background: none;
}
.bold {
font-weight: 700;
}
<div class="img_destination">
<img src="<?php echo SITE_URL?>/lib/skins/gsm/images/featured_destination/gcfv.png" alt="" />
<h2 id="featured_destination">
<span> > > Explore Fuerteventura
<span class="smaller">The island of natural beauty</span>
</span>
</h2>
</div>
and CSS:
h2 > span {
color: white;
font: bold 28px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgba(00, 36, 63, 0.7);
padding: 10px;
}
h2 span.smaller {
padding-left: 20px;
font-size: 10px;
}
Try that. Here is example: http://jsfiddle.net/8PLaB/ Is that what You are looking for?
Your spans .spacer doesn't work because they are empty and browser simply doesn't show them. I think that if You insert in them then they will do their job but it's not good solution in my opinion. Empty tags never are good solution.