Bar on the side of the heading - html

I can't figure this one out. I have a heading (H1) and a colored bar on the right side of the heading. The bar should always cover the area between end of the heading and end of the content area. Something like that:
LOREM IPSUM ================================================
LOREM IPSUM DOLOR SIT AMET =================================
At this point, everything works fine. HTML:
<h1>LOREM IPSUM</h1><hr/>
<div class="clear"></div>
<p>Lorem ipsum dolor sit amet.</p>
and CSS:
h1 { float: left; margin: 0 10px 0 0; font-size: 18px; }
hr { display: block; border-top: 18px solid green; }
.clear { clear: both; }
See jsfiddle
Problem is that this approach doesn't work with multiline heading, it would be perfect to have something like this (so the colored bar appears on the last row):
LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT.
PROIN SAGITTIS DICTUM RISUS A DAPIBUS ========================
Any ideas? :-)

What about this approach on jsfiddle
HTML:
<h1><span>LOREM IPSUM<br />TEST</span></h1>
<div class="clear"></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris odio magna, rhoncus sed leo et, dapibus adipiscing metus. Donec cursus dignissim ipsum sit amet suscipit.</p>
CSS:
h1 {
float: left;
margin: 0 10px 0 0;
font-size: 18px;
display:block;
background:green;
width:100%;
padding:0;
}
h1 span {
background:#FFF;
padding-right:10px;
display:inline-block;
}
.clear { clear: both; }

Related

How to align text to start where other text starts

Right now the text is like this:
Lorem ipsum dolor sit amet consectetur adipiscing
elit vitae orci elementum dictum
I want to be like that:
Lorem ipsum dolor sit amet consectetur adipiscing
elit vitae orci elementum dictum
I want the second text line to start where the first line starts.
the first text line is aligned to right.
try this out. May be helpful
<p>Lorem ipsum dolor sit amet consectetur adipiscing<br>
<span>elit vitae orci elementum dictum</span></p>
<style>
p { float: right; }
span { float: left; }
</style>
Another simple way of doing it is using 2 p tags
In HTML:
<p class="text">Lorem ipsum lorem ipsum</p>
<p class="author">Author</p>
In Css:
.text{
font-size: 15px;
}
.author{
font-size: 12px;
color: grey;
}

How to line through all links of a certain div id and bold mark specific paragraph without affecting others [duplicate]

This question already has an answer here:
How to line-through all links inside a border and bold mark certain text of a paragraph
(1 answer)
Closed 3 years ago.
This is the end-product i'm supposed to make and i'm at this-stage.
How do i line-through in css all porttitor>/a> that is in
without affecting .
And how do i bold mark the last paragraph of both borders as shown in the end-product without bold marking everything?
Also if you want you can tell me if i shouldve written everything in a different way.
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="utf-8" />
<title>Uppgift 4E</title>
<style>
html {
background-color: lightslategrey;
}
body {
margin: auto;
width: 500px;
padding-bottom: 0.1px;
/*knep för div margin */
background-color: #f0ffff;
text-align: center;
font-family: sans-serif;
}
h1 {
Color: purple;
}
#billy {
color: darkred;
border-style: solid;
border-color: purple;
border-width: 1.5px;
border-radius: 5px;
text-align: left;
margin: 10px;
}
#bob {
color: darkgreen;
border-style: solid;
border-color: purple;
border-width: 1.5px;
/* border tjockhet */
border-radius: 5px;
/* rundiga kanter på border */
text-align: left;
margin: 10px;
}
p {
margin-left: 5px;
margin-right: 5px;
}
.two {
font-size: large;
}
.three {
font-size: small;
}
#bob>.two>a {
text-decoration: overline underline;
}
</style>
</head>
<body>
<h1>Uppgift 4E</h1>
<div id="billy">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
<p class="two">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
<p class="three">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
</div>
<div id="bob">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
<p class="two">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
<p class="three">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Suspendisse imperdiet velit sit amet neque tempor et imperdiet augue porttitor.
</p>
</div>
</body>
</html>
Use the <s></s> (strike-through) tag or <del> . The <strike> tag is obsolete is HTML5.
example:
.two a {
text-decoration: line-through;
font-weight: bold;
}
<p>Rachel</p>
<!--Rachel in paragraph tags-->
<p><s>Rachel</s></p>
<!--Rachel in paragraph tags with inner 's' tags-->
<p class="two">I my name is Rachel</p>
<!--line-through css-->
You can also use css
.yourclass a{text-decoration: line-through;}
Regarding bolding text, use font-weight:bold;
Hope this helps
If you can add a class to an HTML element, then you could make a class specifically for bold or line-through, then apply it to what paragraphs that you need to.
Use the text-decoration: line-through; style. It's not obvious what your criterion is for what to affect with this, so I can't suggest a selector.
To mark the last paragraph of each div:
div>p:nth-last-of-type(1) { font-weight: bold; font-size: 110%; }
And you might find fitting the parts together a little easier if you always use:
* { box-sizing: border-box; }
so that container sizes will actually be what a reasonable person would expect them to be.
try this
#bob p:last-child {
font-weight:bold;
}
#bob p:not(.two) a {
text-decoration:line-through;
}

CSS: Right-aligned portion of text with flexible horizontal space

I have an interesting layout issue in CSS. My scenario: Imagine a standard paragraph of text with justified alignment. The last word, however, is the authors name, which needs to be aligned to the right border. Depending on the length of text and the width of the paragraph, this could require a longer distance between the last word of the text and the author's name. It could also happen that the paragraph fills the last line completely, and then the author's name should appear one line below, and still aligned to the right.
I have an image here that illustrates this behavior, see the footnotes:
See that in the first footnote the author ("Der Herausgeber") is aligned to the right, but remains in the last line of the text, while in the second footnote the author ("D. H.") jumps one line down, due to text length.
I have tried to emulate this with the following HTML/CSS:
p {
width: 350px;
text-align: justify;
}
span.author {
display:inline-block;
text-align:right;
max-width:100%;
font-style: italic;
white-space: nowrap;
}
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. <span class="author">The Author</span></p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor massa. <span class="author">The Author</span></p>
So far, the author comes as a separate element, and it jumps to the next line as a separate unit (no wraps allowed). But I have problems aligning it to the right border. I have tried min-width and max-width, which did not work. I have also tried to approach this with flexbox, but until now I did not come even close to a solution. Maybe the HTML code needs to be modified as well. Is there any hint you could give me?
You can try something like this using float:right
p {
width: 350px;
text-align: justify;
}
span.author {
display:inline-block;
text-align:right;
font-style: italic;
white-space: nowrap;
float: right;
}
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. <span class="author">The Author</span></p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor massa. <span class="author">The Author</span></p>
just set float: right; to author span tag
p {
width: 350px;
text-align: justify;
}
span.author {
display:inline-block;
text-align:right;
max-width:100%;
font-style: italic;
white-space: nowrap;
float: right;
}
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. <span class="author">The Author</span></p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor massa. <span class="author">The Author</span></p>
You want something like this? I separated the .author from the p
p {
clear: both;
width: 350px;
text-align: justify;
margin-bottom: 0;
}
.author {
display: inline-block;
float: right;
max-width: 100%;
font-style: italic;
white-space: nowrap;
}
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. </p><span class="author">The Author</span>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor massa. </p><span class="author">The Author</span>

Wall how prevent the formation of the gaps

I creating wall and i have problem.
Better to show it in the picture:
Question is: how can I prevent the formation of the gaps?
html
<div id="wrapper">
<div class="shoot">...</div>
<div class="shoot">...</div>
<div class="shoot">...</div>
</div>
css
#wrapper{
width: 769px;
margin: 0 auto;
}
.shoot{
width: 370px;
height: auto;
float: left;
margin: 7px;
}
#wrapper{
width: 769px;
margin: 0 auto;
background-color: red;
}
.shoot{
width: 370px;
height: auto;
float: left;
margin: 7px;
background-color: blue;
}
.clear-div{
clear: both;
}
<div id="wrapper">
<div class="shoot">Lorem ipsum dolor sit amet, consectetur adipiscing elit. </div>
<div class="shoot">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tristique id justo ac varius. In massa velit, malesuada nec augue at, consectetur pulvinar dolor.
</div>
<div class="shoot">In massa velit, malesuada nec augue at.</div>
<div class="clear-div"></div>
</div>
One way to do it is to enclose the left part in a div, and set that containing div to have float:left and set the right div to have float:right. If you wanted to put multiple items on the right, you could just enclose all the right divs into a container and set float:right on that. Working example: https://jsfiddle.net/32azzrwb/2/

HTML & CSS Layout

I have tried coding the HTML layout in the image below, but as a result does not seem to be working correctly. Any help with the error would be appreciated.
HTML:
<header>
<h1>Header</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pharetra rutrum tem <br> por. Curabitur at rhoncus orci. Donec ante velit, scelerisque vitae tincidunt sit amet.</p>
</header>
<section>
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
</section>
CSS:
body {
font-family: 'open sans';
text-align: center;
color: #333;
}
section {
display: block;
}
h1, h2 {
font-weight: 300;
}
Desired Layout:
You should split your section into two, by headings, so that you can float them separately:
<header>
<h1>Header</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pharetra rutrum tem <br> por. Curabitur at rhoncus orci. Donec ante velit, scelerisque vitae tincidunt sit amet.</p>
</header>
<section>
<article>
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
</article>
<article>
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
</article>
</section>
And for your CSS:
body {
font-family: 'open sans';
text-align: center;
color: #333;
}
section {
display: block;
overflow: hidden;
}
section > article {
box-sizing: border-box;
float: left;
width: 50%;
}
h1, h2 {
font-weight: 300;
}
I recommend using box-sizing: border-box because it will not break the layout when you add padding to the <article> element.
See fiddle here - http://jsfiddle.net/teddyrised/XPGb7/
Wrap your content in left & right containers as:
<header>
<h1>Header</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pharetra rutrum tem <br> por. Curabitur at rhoncus orci. Donec ante velit, scelerisque vitae tincidunt sit amet.</p>
</header>
<section>
<div class="left">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
</div>
<div class="right">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
</div>
</section>
And apply the following style
body {
font-family: 'open sans';
text-align: center;
color: #333;
}
section {
display: block;
}
h1, h2 {
font-weight: 300;
}
.left, .right{
width: 50%;
}
.left{
float: left;
}
.right {
float: right;
}
Working example:
http://jsbin.com/aragem/1/
You will need to wrap your section into two div blocks:
<section>
<div>
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur.
<br>Curabitur at rhoncus orci. Lorem ipsumm.</p>
</div>
<div>
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur.
<br>Curabitur at rhoncus orci. Lorem ipsumm.</p>
</div>
</section>
So you can apply the following style:
section > div {
display: inline-block;
width: 45%;
}
http://jsfiddle.net/samliew/8XJ7F/3/
this will work :
html :
<header>
<h1>Header</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pharetra rutrum tem <br> por. Curabitur at rhoncus orci. Donec ante velit, scelerisque vitae tincidunt sit amet.</p>
</header>
<section>
<div class="left">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
</div>
<div class="right">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur. <br> Curabitur at rhoncus orci. Lorem ipsumm.</p>
</div>
</section>
css :
body {
font-family: 'open sans';
text-align: center;
color: #333;
}
section {
display: block;
}
h1, h2 {
font-weight: 300;
}
.left, .right{
width: 50%;
}
.left{
float: left;
}
.right {
float: right;
}