The text goes over the image and not under it - html

The problem is that when I added an image to my html page,and I tried to write something to continue my working,the text was going over the image.I want the text to be going under the image.I don't want to use 50 "br" tags so that I can write under it.Do you know what's the problem guys ?
.poze {
max-width: 100%;
margin-top: 0.5em;
margin-bottom: 1em;
-webkit-box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px;
background: white;
border: 1px solid #CCC;
border-bottom-left-radius: 5px 5px;
border-bottom-right-radius: 5px 5px;
border-top-left-radius: 5px 5px;
border-top-right-radius: 5px 5px;
padding: 8px;
"
}
.cerculet {
display: block;
}
.cerculet:after {
display: block;
clear: both;
content:' ';
}
.cerculet p {
font-weight: bold;
}
.cerculet h2 {
font-size: 120%;
height: 145%;
width: 1.6em;
height: 1.6em;
text-align: center;
border-radius: 50%;
background-color: black;
color: white;
white-space: nowrap;
float: left;
margin-right: 15px;
}
That was the CSS.Now I'll post the html code:
<h2>
<div class="cerculet">
<h2>2 </h2>
<p>
<font size="5" face="Cambria">
Gripa Spaniola (1918 - 1919):<br>
A ucis intre 50 si 100 de milioane de oameni din intreaga<br>
lume in mai putin de 2 ani
</font>
</p>
</div>
</h2>
<br>
<img src="http://s6.postimg.org/6oyuxe1e9/Spanish_Flu.jpg" class="poze" style="position:absolute; left:150px;">
<div>
<h1>
As you can see,the text doesn't go under my image.How to fix this problem guys?
</h1>
</div>
I hope you'll understand the code.I mean,I used that "4 spaces indent" or whatever and I don't know if that's the right way to post the code.If I copy/paste all,it won't show it right..
https://jsfiddle.net/9hw89uog/

Remove position:absolute from your image styles, it is an inline style in your case

Here is one solution: https://jsfiddle.net/73s1c4h1/2/
<div class="clearfix">
<img src="https://images.nga.gov/images/bindo.jpg" class="poze"style="margin-left:150px;">
<div>
<h1 >
Now the text should be clear of the image and positioned below it.
</h1>
</div>
</div>
This involves using the all famous "clearfix" CSS solution. You will need to wrap the image and text in a div, then place class="clearfix" in that div. The clearfix CSS is here: https://css-tricks.com/snippets/css/clear-fix/
It will force the div element to clear the children elements.
Clearfix CSS:
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content:" ";
clear: both;
height: 0;
}
* html .clearfix { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */
The second solution is a bit simpler; just set position: relative; rather than absolute. https://jsfiddle.net/73s1c4h1/1/
You may also need to change left: 150px to margin-left: 150px

Related

Padding statement transition with background and image and text?

[Note: scroll to the bottom to see exactly what I need]
I am trying to do some kind of simple decoration to my image in HTML. The decoration is to show information about the image with sliding animation only when hovered with the mouse. I tried to make it, but at some point I couldn't figure out how to put the text information in the slider. I tried to make <div> tag to put the text, but it's shows only under the image. While in my situation, I want it to be perfectly behind it.
Here is how I made them:
img.img1, div.img1 {
width: 150px;
margin: 5px 0px 5px 0px;
border: 10px solid rgb(0,0,150);
background: rgb(0,0,150);
padding-right: 0px;
transition: 0.5s;
color: #fff;
font-size: 12px;
writing-mode: vertical-rl;
text-orientation: mixed;
}
img.img1:hover, div.img1:hover {
padding-right: 150px;
}
<img class="img1" src="https://i.pinimg.com/originals/34/b5/86/34b58689b0870284621a661a2c538652.png">
<div class="img1">
<p>Name: Eren Yeager</p>
<p>Age: 20 y.o</p>
<p>Anime: Attack On Titan</p>
<p>Height: 195cm</p>
<p>Living in: Shiganshina District</p>
</div>
In the script above, I don't want the slider to just slide without the text. I want it to slide and sliding the text with it so it'll look like this:
img.img1, div.img1 {
width: 150px;
margin: 5px 0px 5px 0px;
border: 10px solid rgb(0,0,150);
background: rgb(0,0,150);
margin-left: 0px;
transition: 0.5s;
color: #fff;
font-size: 12px;
writing-mode: vertical-rl;
text-orientation: mixed;
}
img.img1:hover {
padding-right: 150px;
}
div.img1:hover {
margin-left: 150px;
}
<img class="img1" src="https://i.pinimg.com/originals/34/b5/86/34b58689b0870284621a661a2c538652.png">
<div class="img1">
<p>Name: Eren Yeager</p>
<p>Age: 20 y.o</p>
<p>Anime: Attack On Titan</p>
<p>Height: 195cm</p>
<p>Living in: Shiganshina District</p>
</div>
In the end. What I want is:
The image information is hiding behind the image (the user can't see them).
Once the user hover over the image, the information will slide from behind the image.
Example:
img.img1, div.img1 {
display: inline-block;
width: 150px;
margin: 0px 0px 0px 0px;
border: 10px solid rgb(0,0,150);
background: rgb(0,0,150);
margin-left: 0px;
transition: 0.5s;
color: #fff;
font-size: 12px;
writing-mode: vertical-rl;
text-orientation: mixed;
}
img.img2, div.img2 {
display: inline-block;
width: 150px;
margin: 0px 0px 0px 0px;
border: 10px solid rgb(0,0,150);
background: rgb(0,0,150);
margin-left: 0px;
transition: 0.5s;
color: #fff;
font-size: 12px;
writing-mode: vertical-rl;
text-orientation: mixed;
}
<img class="img1" src="https://i.pinimg.com/originals/34/b5/86/34b58689b0870284621a661a2c538652.png">
<br>
<br>
<p>When the user hover:</p>
<br>
<br>
<img class="img2" src="https://i.pinimg.com/originals/34/b5/86/34b58689b0870284621a661a2c538652.png">
<div class="img2">
<p>Name: Eren Yeager</p>
<p>Age: 20 y.o</p>
<p>Anime: Attack On Titan</p>
<p>Height: 195cm</p>
<p>Living in: Shiganshina District</p>
</div>
If I needed to use JavaScript to do it, then it's fine I'll use it.
First, put them in a wrapper
Then by using position:absolute; on the <div class="img2"> as well as giving it top:0; right:0; will make the info div cling unto the upper-right corner of the wrapper so that whenever the wrapper extends to the right, the div.img2 will move to the right as well
Next give the img.img2 a z-index:10; to make it float/appear on top of everything else;
Finally assign the :hover to the wrapper. Add padding-left:150px; with a transition: padding .5s and your done.
[Note from Liqui Kal: If the background does not fit perfectly behind the image, then change the statement display: inline-block; to display: inline-flex;]
We can use inline-flex / inline-grid to center the image using align-items:center to vertically align the image but we can't justify it because when justified to the center, the image will move along the expansion of the parent div. - StepPen-codes
let radioBtn = document.querySelectorAll('input[type=radio]')
for (let btn of radioBtn) btn.addEventListener('change', function(event) {
document.documentElement.style.setProperty('--text-align', event.target.value)
})
:root {
--text-align: left;
}
.imgWCap {
position: relative;
display: inline-flex;
align-items: center;
background: rgb(0, 0, 150);
transition: 0.5s;
}
.imgWCap:hover {
padding-right: 140px;
background: rgb(0, 0, 150);
}
.img2 {
padding: 10px;
}
img.img2 {
position: relative;
width: 150px;
margin: 0;
z-index: 10;
}
div.img2 {
position: absolute;
right: -10px;
font-size: 12px;
color: #fff;
text-align: var(--text-align);
/*Here is the the text align at work;*/
writing-mode: vertical-rl;
}
HOVER OVER THE PICTURE <br>
<div class="imgWCap">
<img class="img2" src="https://i.pinimg.com/originals/34/b5/86/34b58689b0870284621a661a2c538652.png">
<div class="img2">
<p>Name: Eren Yeager</p>
<p>Age: 20 y.o</p>
<p>Anime: Attack On Titan</p>
<p>Height: 195cm</p>
<p>Living in: Shiganshina District</p>
</div>
</div>
<br>Pick the text-alignment that you need.
<form>
<label for=left>Left</label><input id=left name=align type=radio value=left>
<label for=center>Center</label><input id=center name=align type=radio value=center>
<label for=right>right</label><input id=right name=align type=radio value=right>
</form>

Adding Thumbnail Image With CSS Border

I am trying to recreate what Lynda.com does with their course listing thumbnail image (see here). I am not sure how to place the image inside of my already existing code here. What I am not sure of is the dimensions of what the image should be each time and I am not sure how to handle the image resizing if my description is really long and widens the border. How would I do this?
If worse comes to worse, I will keep the descriptions small. I also realize that if the image also gets bigger if the description gets longer, the image getting bigger as a side effect will not look consistent with the other thumbnail images on the page.
HTML:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
<a class="course_list_link" href="">
<p class = "course_list_border">
<strong> Title </strong> <br/> <br/>
description <br/> <br/>
skill_level  
date  
Views: views  
subject </p> </a>
CSS:
.course_list_border{
border-style: solid;
border-width: 1px;
border-color: #DCDCDC;
padding: 10px;
word-wrap: break-word;
}
.course_list_border:hover{
background-color: #F8F8F8;
cursor: pointer;
}
.course_list_link{
color: black;
}
.course_list_link:hover{
text-decoration: none;
color: black;
}
body {
min-height: 400px;
margin-bottom: 100px;
margin-top: 0%;
clear: both;
padding-top: 55px;
font-family: 'Roboto', sans-serif;
font-size: 16.5px;
}
I have made some changes in your css and HTML file
.course_list_border{
border-style: solid;
border-width: 1px;
border-color: #DCDCDC;
padding: 10px;
word-wrap: break-word;
}
.course_list_border:hover{
background-color: #F8F8F8;
cursor: pointer;
}
.course_list_link{
color: black;
display: inline-block;
width: 30%;
}
.course_list_link:hover{
text-decoration: none;
color: black;
}
body {
min-height: 400px;
margin-bottom: 100px;
margin-top: 0%;
clear: both;
padding-top: 55px;
font-family: 'Roboto', sans-serif;
font-size: 16.5px;
}
<a class="course_list_link" href="">
<p class = "course_list_border">
<strong> Title </strong> <br/> <br/>
description <br/> <br/>
<img src="https://via.placeholder.com/200X150" alt="Lights" style="width:100%"/>
skill_level  
date  
Views: views  
subject </p>
</a>
As you are using bootstrap you can also make use of existing classes for creating this kind of image thumbnails
https://getbootstrap.com/docs/4.0/content/figures/
Generally, it's far better to separate all items into elements, instead of concatenating them into a single paragraph. For example:
<style>
a.course_list_link {
display: block;
width: 300px;
border: 1px solid #DCDCDC;
border-radius: 5px;
text-decoration: none;
font-family: 'Roboto', sans-serif;
transition: all, 0.3s, ease;
}
a.course_list_link:hover .thumbnail {
filter: grayscale(50%);
}
a.course_list_link:hover {
background-color: whitesmoke;
}
a.course_list_link:active {
background-color: white;
}
a.course_list_link:hover p.description {
color: black !important;
}
.course_list_link .thumbnail {
background-color: grey;
background-size: cover; /* Guarantees your background always fits the thumbnail size, no matter its aspect ratio */
height: 150px;
}
.course_list_link .play-button {
opacity: 0.5;
height: inherit;
width: inherit;
background-size: 50px;
background-repeat: no-repeat;
background-position: center;
}
.course_list_link:hover .play-button {
background-image: url('https://www.drury.edu/images/socialmediaicons/play_button.png');
}
.course_list_link .content-area {
margin: 5px;
}
.course_list_link h2 {
color: black;
font-weight: 500;
font-size: 18px;
margin: 0;
}
.course_list_link p.description {
margin: 0;
margin-bottom: 5px;
font-size: 14px;
color: grey !important;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
color: black;
}
.metadata {
font-size: 12px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.column {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.metadata .skill {
color: grey;
}
.metadata .date {
color: grey;
}
.metadata .views {
color: grey;
}
.metadata .subject {
font-weight: bold;
color: grey;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<a class="course_list_link" href="#">
<div class="thumbnail" style="background-image: url('https://img-aws.ehowcdn.com/560x560p/photos.demandstudios.com/getty/article/188/230/dv030463.jpg');"><!-- Set the bg image of this element in CSS -->
<div class="play-button"></div>
</div>
<div class="content-area">
<h2>Title</h2>
<p class="description">Description of the video, which may or may not be very long depending on the type of video, and what is chosen to display, and how many lines the space is allowed to occupy in the thumbnail.</p>
<div class="metadata">
<div class="column">
<div class="skill">Skill level</div>
<div class="views">Views</div>
</div>
<div>
<div class="date">Date</div>
</div>
<div>
<div class="subject">Subject That is Too Long And Will Inevitably Overflow to New Lines If Not Blocked by Some Sort of CSS Trick</div>
</div>
</div>
</div>
</a>
I also like to set the thumbnails in CSS. That way, even if your thumbnail changes size, it is always cropped at the same size within the HTML element. However, it's always good to ensure that images are not oversized so that the page loads quickly; therefore, making real thumbnails is always a good idea.
Just as a side note, it's general CSS good practice to use hyphens instead of underscores, so .course_list_link becomes .course-list-link.

Show text in vertical format

<span class="helpBtn">HELP</span> help text should stay inside span
It should display like this......
I have tried text transform but it isn't giving me correct solution.
Actually i don't want to change text inside span. It should stay inside span like i have shown. It shouldn't be edited.
Try breaking word in css. If you need more spacing and your words are breaking each 2 or more letters use letter-spacing or just padding.
CSS:
.wrapper {
position: fixed;
background-color: green;
top: 30px;
left: 0;
width: 20px;
border-radius: 0 10px 10px 0;
color: white;
font-size: 13px;
padding: 5px;
word-wrap: break-word;
}
HTML:
<div class="wrapper">
HELP
</div>
https://fiddle.jshell.net/1hwd5j7g/
try below code. it would definitely help you.
<div class="vertical-text">Hello Vertical Texter!</div>
<style>
.vertical-text {
background: #e23737 none repeat scroll 0 0;
border: 1px solid #b52c2c;
box-shadow: 2px -2px 0 rgba(0, 0, 0, 0.1);
color: #fff;
float: left;
margin-left: 40px;
padding: 10px;
text-transform: uppercase;
transform: rotate(90deg);
transform-origin: left top 0;
}
</style>
with CSS:
<style>
h1 span { display: block; }
</style>
<h1>
<span> H </span>
<span> E </span>
<span> L </span>
<span> P </span>
</h1>
With Javascript:
<style>
h1 span { display: block; }
</style>
<h1><span> HELP </span></h1>
<script>
var h1 = document.getElementsByTagName('h1')[0];
h1.innerHTML = '<span>' + h1.innerHTML.split('').join('</span><span>') +'</span>';
</script>
Source: http://code.tutsplus.com/tutorials/the-easiest-way-to-create-vertical-text-with-css--net-15284

CSS Float does not stretch Div Height

I have had this problem for a long time when working with HTML/CSS and Floats.
In the image you can see I have a Box Div that is Floated left as there is many of these Boxes. Inside the Box I have a <UL> List. The List items <li> are also Floated left.
As you can see in the image, the List items do not make the Box Div that they are inside of Expand. I have tried several thing without much luck and was hoping someone with more experience could help? I cannot set a fixed height on the Box Div as the number of icons is always different and it needs to expand to fix them.
Live demo: http://jsfiddle.net/jasondavis/u5HXu/
<div class="module-box">
<div class="module-box-title">
<h4><i class="icon-cogs"></i>Admin Settings</h4>
<div class="tools">
-
</div>
</div>
<div class="module-box-body" style="display: block;">
<ul>
<li>
<a href="#">
<img src="http://cp.codedevelopr.com/modules/password_assistant/assets/icon.png" border="0">
<span class="module-icon password_assistant"></span>
</a><br>
Change<br>Password
</li>
<li>
<a href="#">
<img src="http://cp.codedevelopr.com/modules/password_assistant/assets/icon.png" border="0">
<span class="module-icon password_assistant"></span>
</a><br>
Change<br>Password
</li>
<li>
<a href="#">
<img src="http://cp.codedevelopr.com/modules/password_assistant/assets/icon.png" border="0">
<span class="module-icon password_assistant"></span>
</a><br>
Change<br>Password
</li>
</ul>
</div>
</div>
CSS
/* Modules homepage */
.module-box {
margin: 0px 0px 25px 25px;
padding: 0px;
float: left;
width: 464px;
}
.module-box-title {
margin-bottom: 0px;
padding: 8px 10px 2px 10px;
border-bottom: 1px solid #eee;
color: #fff !important;
background-color: #333;
height: 51px;
line-height: 45px;
border-radius: 3px 3px 0 0;
}
.module-box-title h4 {
display: inline-block;
font-size: 18px;
font-weight: 400;
margin: 0;
padding: 0;
margin-bottom: 7px;
}
.module-box-title .tools {
display: inline-block;
padding: 0;
margin: 0;
margin-top: 6px;
float: right;
}
.module-box-title .tools a {
font-size: 31px;
color: #fff;
text-decoration: none;
line-height: 29px;
}
.module-box-body {
background-color: #fff;
border: 1px solid #ccc;
border-top: 0;
padding: 10px;
clear: both;
}
.module-box-body a {
font-family: 'Source Sans Pro', sans-serif;
font-size: 11px;
color: #888;
text-decoration: none;
}
.module-box-body li {
float: left;
margin: 0 12px 0 0;
list-style: none;
}
You need to clear your floats using a clearfix or clearing element.
Method #1 clearfix
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
Then you add the class on the containing element
<div class="module-box-body clearfix" style="display: block;">
http://jsfiddle.net/u5HXu/8/
Method #2 Clearing Element
.clear {
clear: both;
}
Then you add the following HTML after your floated elements.
<div class="clear"></div>
http://jsfiddle.net/u5HXu/9/
You can use the overflow: hidden trick on the parent container (..module-box-body) ;) fixes everything.
http://jsfiddle.net/teddyrised/ct6gr/
Change your .module-box-body li to
.module-box-body li {
display: inline-block;
margin: 0 12px 0;
list-style: none;
}
Updated fiddle.
Try applying overflow:auto to the container, the one whose height you want to resize based on the height of its contents (the floated items).
I'd add a jsfiddle link but it's not been working at all for me recently. :/

Inner div to scroll if outer div is too small?

I'm trying to make a sidebar which on a website which will have a "panel" in it containing
contact info. The problem is that on smaller screens, the text overflows the background.
Here is the CSS, where #navigation is the outer div and the inner div is called .innerPanel HTML to follow:
#navigation{
position: absolute;
left: 1.5625em;
top: 1.5625em;
bottom: 1.5625em;
display: block;
width: 12.5em;
background: navy;
border-right: 1px solid navy;
text-align: center;
background: #B6D2F0;
padding: 5px;
color: #4A4A49;
overflow: hidden;
}
#navigation .innerPanel{
min-height: 200px; /* supply current height here */
height: auto;
overflow: auto;
}
.titleHead{
display: block;
padding-top: 0.9em;
overflow: auto;
}
/* inverted corners for the links */
#navigation #links {
position: relative;
padding-top: 30px;
}
#navigation #links div div div h3{
border-top: 1px solid navy;
border-bottom: 1px solid navy;
color: navy;
padding: 0px;
margin: 0px;
margin-top: 1px;
line-height: 1.2em;
}
#navigation div div div div ul{
list-style-type: none;
margin: 0px;
padding: 0px;
}
#navigation div div div div ul li{
text-align: center;
}
#navigation div div div div ul li a{
display: block;
text-decoration: none;
font-weight: bold;
color: #B6D2F0;
padding: 0px;
padding-left: 0;
line-height: 2.5em;
background: navy;
border-bottom: #D8F4F2 1px dashed;
}
#navigation div div div div ul li a:hover{
display: block;
text-decoration: none;
font-weight: bold;
color: #D8F4F2;
background: #0000A2;
}
#navigation div div div div ul #last a{
border-bottom: 0px;
}
`
Here is the HTML fragment. The nested div tags were for rounded corners, which were "nixed" by the client
<div id="navigation">
<div id="logo" class="box">
<div>
<div>
<div style="text-align: center;">
<img src="./images/pictures/cbk-logo-sm.gif" alt="Logo" />
</div>
</div>
</div>
</div>
<div id="links" class="box">
<div>
<div>
<div> <ul>
<li id="home">
Home
</li><li>
Applications
</li><li id="last">
About
</li>
</ul><div class="innerPanel"><div class="innerMost"><h4 class="titleHead">
Contact Information</h4>
<h5 style="margin: 0.8em 0 0 0; padding: 0;">City Office (September-June)</h5>
<p style="font-size: 0.75em; margin: 0; padding: 0;">
<em>Phone:</em> 555-555-5555<br />
<em>Fax:</em> 555-555-5555<br />
<em>Email:</em> email#provider.com<br />
<em>Address:</em> 123 Main Avenue Somewhere, IL 11234
</p>
<h5 style="margin: 0.8em 0 0 0; padding: 0;">Camp (July & August)</h5>
<p style="font-size: 0.75em; margin: 0; padding: 0;">
<em>Phone:</em> 987-654-3210<br />
<em>Fax:</em> 123-456-1234<br />
<em>Email:</em> email#provider.com<br />
<em>Address:</em> 456 Centre Road, Nowhere, AL 67891
</p></div></div> </div>
</div>
</div>
</div>
</div>
I need a cross-browser solution to make innerPanel dynamically add a scrollbar to itself so that on smaller screens, the content is clipped but accessible via scroll...
Preferably, the solution should be pure CSS.
Any ideas?
EDIT: I apologize for the ambiguity. I have a sidebar, called #navigation. It contains a logo, the menu and the contact information. I want the contact info to scroll where needed.
Everything else seems to display normally on 800x600 screens and up.
EDIT: As it stands now, innerPanel is a fixed height. I would like it to grow when possible, and if there is enough room, eliminate the scrollbar.
Please note that there is an HTML div not mentioned in the CSS, which is contained inside of innerPanel.
I am a little unclear what you are asking, but it seems to me you either want overflow:auto on the #navigation element, or depending on your content and why it has a fixed height:
#navigation .innerPanel {
max-height: 200px; /* supply current height here */
height: auto;
overflow: auto;
}
DOES NOT WORK IN IE6
IE6 does not support max-height.