Sliding out widget on hover - html

I want to make sliding out on hover widgets with text. I want to make semicircles with the main heading. When you hover on the semicircle, the text should appear. I am currently standing on it
My actual code:
<div class="col-md-4 box_industries">
<div>
<div class="image fill">
O nas
</div>
<div class="content">
<h5>O nas</h5>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vehicula auctor vulputate. Aenean massa lectus, tempor hendrerit faucibus eu, euismod sit amet lorem. Aliquam ante arcu, tempor id augue eget, tristique tincidunt ipsum. Phasellus dignissim eu nisl in commodo. Maecenas erat diam, tristique eu arcu vulputate, vehicula vulputate tellus.
</div>
</div>
</div>
.box_industries
{
background: grey;
overflow: hidden;
text-align: center;
position: relative;
min-height:300px;
border-radius:999px;
color:#fff;
}
.box_industries .content
{
background: rgba( 0, 0, 0, 0.9 );
bottom: -100%;
color: #fff;
height: 100%;
left: 0%;
text-align: center;
position: absolute;
transition: bottom 0.5s ease;
width: 100%;
font-size:14px;
}
.box_industries:hover .content
{
bottom: 0%;
}

Try to use CSS :hover Selector. Example: div:hover {top: 100px;} but it will be work only when mouse still over the element, or you can change the top using JS: document.getElementById("elem").style.top = "100px"; but if cursor goes out the element it will be having a top 100px (not past value);

Here's what I'd do - use simple hover effects as ch1puha mentions, add some transition duration. I've put together an example for you: https://jsfiddle.net/59tvxe2f/
<div id="container">
<div class="circle">
<h2>HOVER ME</h2>
<p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
</div>
</div>
/* Globals */
html, body {height:100%; margin:0; padding:0;}
* {box-sizing: border-box;}
#container {
padding:20px;
}
.circle {
margin:0 auto;
height:200px;
width:200px;
background-color:red;
border-radius:100px;
transition:300ms;
text-align:center;
color:white;
font-family:Arial, sans-serif;
font-size:20px;
}
.circle:hover {
height:500px;
transition:300ms;
}
.circle:hover > h2{
padding-top:75px;
transition:300ms;
}
.circle:hover > p{
opacity:1;
transition:300ms;
}
h2 {padding-top:85px; transition:300ms;}
p {font-size:16px;padding:20px; opacity:0; transition:300ms;}

Related

Background color to fit content on <p> tag

Scenario :
I can't figure out how to have a 50% opacity "box" behind a text that just cover the text and not a whole square.
I have a h2-tag that i have specified this CSS to:
background: rgba(0, 0, 0, 0.5);
width: fit-content;
Problem :
I tried the same thing on a p-tag, but that does not work...
this is working fine. Check This
h2{
background: rgba(0, 0, 0, 0.5);
width: fit-content;
}
p{
background: rgba(0, 0, 0, 0.5);
width: fit-content;
}
<h2>Some Text Here</h2>
<p>Some Text Here</p>
if you want color behind the text then use <mark> tag
mark{
background: rgba(0, 0, 0, 0.5);
}
<mark> test</mark>
Try this way.
p{
background: rgb(0, 0, 0 , 0.5);
opacity: 0.5;
}
<p>Hello world</p>
This is works for me. :)
You need an inline element like <span> and apply the same color to this inline element. Other wise you can apply display:inline to your <p>.
p{
background: rgba(255, 0, 0, .5);
display: inline;
}
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris purus risus, tincidunt vel accumsan et, tempus placerat nisi. Suspendisse ornare, elit vitae vulputate pulvinar, arcu mi pretium lorem, et ultricies elit purus interdum nulla. Suspendisse vel erat id tellus venenatis viverra. Donec et mauris efficitur<p>
Hope this is you are looking for.
.back {
background-color: red;
width: 100%;
height: 200px;
text-align: center;
padding-top: 20px;
}
h2 {
color: #000000;
font-size: 35px;
font-weight: 900;
}
p {
color: #ffffff;
font-size: 16px;
}
<div class="back">
<h2>This is h2 text</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</p>
</div>
Please check the above code.
p{
background-color:lightgreen;
margin:10px;
}
p.p{
background-color:lightpink;
margin:10px;
}
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p class="p">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. </p>
<p class="p">Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.</p>
<p class="p">Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur.</p>
<p class="p"> Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
You make the <p> inline. See below snippet.
This also work with width: 100%;.
p {
background: rgba(255, 0, 0, 0.2);
width: auto;
display: inline;
}
<p>
hello world
</p>

Div overlaps text in mobile preview

I have a div block which contains an image and text:
<div style="position: relative; margin-bottom: 90px;"><img src="https://cdn2.hubspot.net/hubfs/4022333/Blog/TOFU/quote.png" style="width: 112px;">
<div style="position: absolute; top: 50px; left: 78px;">
<p style="font-family: AvenirLight; color: #74818a; font-size: 36px; line-height: 45px; font-style: italic;">“Enabling understanding means being able to communicate effectively”</p>
</div>
</div>
I've applied margin-bottom: 90px; on the parent div to create a gap between the div and any p tags which may be below it.
It works fine on full display, but on mobile, it looks like this:
As you can see, it's overlapping the following p tags after the div. How can I fix this? Ideally I want a 20px gap between the parent div and anything outside the div.
Edit:
I feel like my approach is wrong. I.e. if I remove margin-bottom: 90px; from the code above, the div will still overlap any following p tags:
The reason why other elements are overlapping your quote element, is because the element which is primarily deciding the height of the element (the div which contains the paragraph) is having an absolute position. An absolute positioned element is no longer part of the parent (unless the parent has a relative position). So, in this case, because the div with the paragraph is no longer 'part' of the parent, the parent will only have a height based on the static/relative positioned elements. Which is the image.
As a solution you can switch the absolute position of your p element to the img element. You know the width and the height of the image, so you can set a padding for your paragraph element. In this case the height of the parent div (which is called .quote-wrapper in my example) will have the correct height so elements above or below .quote-wrapper won't overlap your element.
.quote-wrapper {
padding: 40px 0;
}
.quote-wrapper .quote-image {
width: 120px;
height: 100px;
position: absolute;
}
/* Set position to relative so the element won't be overlapped by the image */
.quote-wrapper > p {
font-family: AvenirLight;
color: #74818a;
font-size: 36px;
line-height: 45px;
font-style: italic;
padding: 80px 0 0 80px;
margin: 0;
position: relative;
}
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div class="quote-wrapper">
<img src="https://cdn2.hubspot.net/hubfs/4022333/Blog/TOFU/quote.png" class="quote-image" />
<p>
“Enabling understanding means being able to communicate effectively”
</p>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
You can put margin-top inside the tag p. I recommend that you put an id or class for each tag (div,p...), to make the structure easier and that labels do not overlap.
Try editing your html code this way and add this media query to your code.
<div style="position: relative; margin-bottom: 90px;"><img src="https://cdn2.hubspot.net/hubfs/4022333/Blog/TOFU/quote.png" style="width: 112px;">
<div style="position: absolute; top: 50px; left: 78px;" class="quotation">
<p style="font-family: AvenirLight; color: #74818a; font-size: 36px; line-height: 45px; font-style: italic;">“Enabling understanding means being able to communicate effectively”</p>
</div>
</div>
#media screen and (max-width: 767px) {
.quatation {
position: static !important;
}
}
The problem is that is position absolute on title. i recommended following structure for free hesitate for all resolutions and devices.
.block-quote {
display:block;
margin:0;
padding:20px 0 0 70px;
background:url(https://cdn2.hubspot.net/hubfs/4022333/Blog/TOFU/quote.png) 0 0 no-repeat;
}
h2 {
font-family: 'AvenirLight';
color: #74818a;
font-size: 36px;
line-height: 45px;
font-style: italic;
}
<div class="block-quote">
<h2>“Enabling understanding means being able to communicate effectively”</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sollicitudin vulputate vehicula. Morbi fermentum elit lobortis nibh molestie, nec facilisis elit tempor. Nullam porta lectus erat, et hendrerit diam dictum at. Vestibulum sed enim turpis. Sed vehicula venenatis cursus. Mauris sit amet venenatis velit. Nullam ut purus erat. Nam posuere lorem at est ultrices luctus.</p>
</div>

What should I do to have a background image in the centre with low opacity?

I tried to have a background image right in the centre but with low opacity.Everytime I wrote my code it either was in the centre or with low opacity but not both simultaneously.What should I do?
<head>
<style>
body {
background-image: url('image.png');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
</style>
</head>
However,this code below is the one that provides opacity to the image but not necessarily put it in the center
image{
background:url('image.png');
background-size:100%;
height: 250px;
width: 200px;
position: fixed;
left:0;
right:0;
z-index: -1;
filter:opacity(30%);
-webkit-filter:opacity(30%);
}
.heading{
z-index: 2;
position: fixed;
left: 10px;
}
.color{
height: 150px;
position: fixed;
z-index: 1;
left: 0;
right: 0;
background-color:#ffffff;
}
You can try using pseudo-element and put it below content and then simply control opacity property like this :
body {
margin: 0;
padding: 50px;
position: relative;
background: red; /* added this to see the effect of opacity */
}
body p {
position: relative;
z-index: 1;
color: #fff;
}
body:before {
content: " ";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-image: url(https://lorempixel.com/1000/800/);
/* Control image position */
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
/* -- */
z-index: 0;
opacity: 0.5;
/* control opacity with this*/
}
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas vel vehicula nibh. Aliquam sit amet risus urna. Mauris ac faucibus felis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc dapibus urna velit,
vitae tincidunt nulla semper quis. Morbi ullamcorper ex erat. Donec magna ipsum, efficitur ac commodo nec, dapibus at lacus. Morbi vitae maximus est, mattis ornare lorem. Sed pellentesque lacus est, non finibus lectus molestie quis. Maecenas sit amet
consectetur massa. Sed aliquet pharetra tellus, efficitur venenatis nisl fermentum non. Nu</p>
Declaring your background image on an element that you can maintain as a separate concern from other page elements, and further style accordingly, like adjusting the opacity, is a method I would recommend exploring.
Styles attributed to the element in question:
.site-bg {
background-image: url(https://lorempixel.com/1000/800/);
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
opacity: .5;
z-index: -1;
background-size: cover;
background-position: center center
}
A Code Snippet has been embedded below to demonstrate a straight-forward method to achieve the specified intended result, utilizing some common site elements and structure to add further context to the demonstration.
$('#toggle-content, #gaaah-hide-it').on('click', function() {
$('.article-body').fadeToggle();
});
* {
box-sizing: border-box;
}
body {
max-width: 1200px;
width: 90%;
margin: auto;
}
footer {
margin-top: 20px;
}
.article-body {
display: flex;
border: 1px solid #ddd;
border-radius: 10px;
overflow: hidden;
}
article {
flex-basis: 70%;
padding: 10px;
background: white;
border-right: 1px solid #ddd;
}
aside {
flex-basis: 30%;
background: whitesmoke;
padding: 10px;
}
.site-bg {
background-image: url(https://lorempixel.com/1000/800/);
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
opacity: .5;
z-index: -1;
background-size: cover;
background-position: center center
}
#toggle-content {
cursor: pointer;
transition: .7s;
background: transparent;
padding: 5px;
}
#toggle-content:hover {
background: black;
color: white;
}
#gaaah-hide-it {
border-radius: 100%;
float: right;
border: 1px solid;
width: 20px;
text-align: center;
transition: .7s;
background: whitesmoke;
cursor: pointer;
}
#gaaah-hide-it:hover {
background: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<head>
<!-- Only here for context to help you better understand -->
</head>
<div class="site-bg">
<!-- You'll use this arbitrary div here to attribute your background-image styles to -->
</div>
<header>
<h1>Here be dragons</h1>
</header>
<p>What will this look like with some page content? <span id="toggle-content">click here</span></p>
<section class="article-body" style="display: none;">
<article>
<h2>I did a code</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Aute proident, deserunt in exercitation dolore exercitation consequat. sunt Excepteur nulla proident, sit fugiat pariatur. cupidatat laborum. ut pariatur. quis eiusmod minim incididunt voluptate enim anim laborum. aliqua. eu aliquip et nisi proident,
cupidatat in sed esse dolore minim anim non deserunt mollit Lorem proident, magna incididunt sed et exercitation officia aliqua. nisi anim et mollit nisi dolore do aliqua. labore.</p>
<p>Culpa tempor aliqua. cillum laborum. consectetur quis ut amet, qui ut deserunt consectetur consectetur incididunt officia proident, culpa laboris eiusmod irure sed aliquip aute sunt adipisicing reprehenderit nulla sint dolore eu quis aliquip officia
amet, mollit quis dolor nostrud velit nostrud laboris esse nulla id ut aute et reprehenderit officia do Ut in magna laborum. nulla sed in do mollit ullamco.</p>
</article>
<aside>
<span id="gaaah-hide-it" title="hide me, I'm shy">×</span> Some things on the side...
</aside>
</section>
<footer>
<!-- Only here for context to help you better understand -->
</footer>
</body>

Display button right-aligned below paragraph

I've got a text-paragraph and a button.
I want to display the button right-aligned below the text but I can't quite get it to work.
This is how it currently looks like:
How can I do this WITHOUT float (it falls in the element below it if I set float: right)
Just use the desired vertical-align, e.g.
button {
vertical-align: -75%;
}
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
<button>Button</button>
</p>
This could do it width inline-block + transform.
JsFiddle
a {
display: inline-block;
background: yellow;
padding: 5px 10px;
transform: translateY(100%);
}
I've got a text-paragraph and a button. I want to display the button right-aligned below the text but I can't quite get it to work.
Link text
Is this what you're looking for?
div {
width: 400px;
}
button {
display: inline-block;
background: orange;
padding: 5px 10px;
margin-left: 300px;
width: 100px;
}
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."<button>Click Me</button>
One way could be putting it in a div, with the width set to 100% (that is, if the div and paragraph share parents) and then set the divs text-align to right.
<div>
<p>....</p>
<div style="width:100%; text-align:right;">
<button>click here</button>
</div>
</div>
If I understand your question correctly, the following fiddle should work. Here is the fiddle: http://jsfiddle.net/cLyycy3d/
CSS:
button {
float: right;
}

Navigation won't "break" or fall onto new row if centered

I'm trying to create a website for my cousin who does not know a single line of code. And I barely do :D
Well I can get my head around some basic stuff.
But I can't just seem to figure out how to do this Nav-bar. The problem that I face is I'm trying to make the website responsive. As it is now the code works fine when resizing the window to a smaller size (i.e the nav-bar stacks onto itself as supposed). BUT I want the four (4) links to be centered in relation to the header.
The header, as you will see has a padding on both sides of 13%. I then want the navbar to be centered in the remaining 74%. Hopefully this make any sense, I bet you guys are way better than me at doing this.
I do not have the website hosted yet so you will have to see the code for yourself.
I've tried to add width:25%; and width:calc(100/4); But when I add width to it, it gets centered as I want it to be, but it does not fall/break onto a new row, it glides into each other.
Thanks a massive for any help!
Here is the HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/index.css">
<title>Fanny Schwarz Design</title>
</head>
<body>
<div id="container">
<div id="header">
<img src="main_img/fanny_schwarz_logo.jpg" class="logo" alt="Fanny Schwarz logo">
</div>
<div id="navigation">
<ul>
<li>
<a href="home.html">
♦<span style="font-size:2em;">home</span>♦
</a>
</li>
<li>
<a href="portfolio.html">
♦<span style="font-size:2em;">portfolio</span>♦
</a>
</li>
<li>
<a href="about.html">
♦<span style="font-size:2em;">about</span>♦
</a>
</li>
<li>
<a href="contact.html">
♦<span style="font-size:2em;">contact</span>♦
</a>
</li>
</ul>
</div>
<div id="content">
<h2>Page heading</h2>
<p>Lorem ipsum dolor sit amet consect etuer adipi scing elit sed diam nonummy nibh euismod tinunt ut laoreet dolore magna aliquam erat volut. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
<p>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</div>
<div id="footer">
<div>
<span style="vertical-align:middle; font-size:2em;">©</span>
<span style="font-size:1em; vertical-align:middle;">fanny schwarz 2014</span>
</div>
</div>
</div>
</body>
</html>
Here is the CSS:
body {
background-color:#F9E1F7;
font-family:monospace;
}
p {
text-align:left;
}
#container {
padding-left:13%;
padding-right:13%;
background:#F9E1F7;
margin:0 auto;
}
#header {
background:#ccc;
text-align:none;
max-height:290px;
}
.logo {
position:relative;
max-height:100%;
max-width:100%;
left:0;
}
#navigation {
width:100%;
background:#F9E1F7;
letter-spacing:2px;
}
#navigation ul {
overflow:hidden;
margin:0;
padding:0;
}
#navigation ul li {
list-style:none;
float:left;
text-align:center;
display:inline-block;
width: 25%;
}
#navigation li a {
display:block;
color:#000;
text-decoration:none;
padding:10px;
}
#content {
clear:left;
padding:20px;
}
#content h2 {
color:#000;
font-size:160%;
text-align:left;
margin:0 0 .5em;
}
#footer {
background:#F9E1F7;
text-align:center;
height:1%;
font-size:15px;
max-height:50px;
line-height:50px;
padding:20px;
}
#navigation li a:hover, #navigation li a:active {
text-decoration:underline;
}
Here are the CSS styles that were causing your problem:
#navigation ul {
overflow:hidden;
}
#navigation ul li {
float:left;
text-align:center;
width: 25%;
}
Change them to:
#navigation ul {
width:100%;
text-align:center;
margin:0 auto;
padding:0;
}
#navigation ul li {
list-style:none;
display:inline-block;
}
That should fix your problem. The reasons:
overflow:hidden will hide things that move out of your li on mobile browsers.
There's nothing wrong with float:left, except that you were trying to center the lis. You cannot do that when a float:left style is applied.
I think you meant to put text-align:center on the ul, not the li.
width:25% was causing your lis to overlap instead of breaking to the next line.
JSFIDDLE HERE.
Hope this helps!