Hide/show text in body on hover of child element - html

I'd like to initially hide text in my body, but show it once an element in a child div is hovered over. So In this case, I want them both to initially start out as display: none but then when I hover over the letter "H" I want "Text A" to show. When I hover over letter "E" I want "Text B" to show. I don't want to put my #content elements inside of my #word elements. I want to keep them as separate divs.
Any Ideas?
(See Fiddle below)
HTML:
<div id="word">
<h1><a id="h" class= "letter" href=#>H</a></h1>
<h1><a id="e" class= "letter" href=#>E</a></h1>
<h1><a id="l" class= "letter" href=#>L</a></h1>
<h1><a id="l2"class= "letter" href=#>L</a></h1>
<h1><a id="o" class= "letter" href=#>O</a></h1>
</div>
<div id="content">
<div id="textA">Text A</div>
<div id="textB">Text B</div>
</div>
CSS:
body {
font-family: 'Chango', cursive;
font-size: 115px;
color: white;
text-shadow: 5px 5px 5px #000;
width: 100%;
height: 100%;
margin: 0px;
background: black;
}
#name {
position:absolute;
height:100%;
width: 70%;
display: table;
padding: 0 15% 0 15%;
background: black;
}
h1 {
display: table-cell;
vertical-align: middle;
text-align:center;
height: 1em;
}
a {
/*border: 1px solid black;*/
display: inline-block;
line-height: 89%;
overflow: hidden;
}
a:visited, a:active {
text-decoration: none;
color: white;
/*color: #E8E8E8;*/
}
a:link {
text-decoration: none;
color: white;
text-shadow: 3px -3px 0px black, -2px 2px 5px #0056b2;
}
a:hover {
text-shadow: 5px 5px 5px #000;
color: white;
}
Fiddle: http://jsfiddle.net/ADfhj/1/
PS- I've tried the following CSS to no avail:
#textA {
display: none;
}
#word:hover #textA {
display: block;
}

There is no way achieving it using css only. However you can try simple javascript/jquery.
$('.letter').mouseover(function(){
var cont = $(this).attr('id');
$('#content>div').hide();
$('#text_'+cont).fadeIn();
});
Check the Fiddle

Related

Why is my text flowing outside my Paragraph Element?

I have a widget that will display a listing of comments. The intent is...for the element to simply automatically expand to display the comment (text).
However, no matter what I try, either the element (itself) expands beyond the page...or the text flows beyond the bounds of the element(s).
I would like it to:
Adjust to parents width (if possible)
Auto-expand the height to fully-display the comment (if possible)
I've been trying:
Combinations of fixing inline-size, word-wrapping & overflow
But I cant seem to make it work
.commenting-context {
background-color: #fff;
border: 1px solid #B9B9B4;
display: none;
position: absolute;
margin-top: 20px;
min-width: 500px;
padding: 10px;
-webkit-box-shadow: 0 0 3px 1px #2e6da4;
-moz-box-shadow: 0 0 3px 1px #2e6da4;
box-shadow: 0 0 3px 1px #2e6da4;
}
.commenting-context section header {}
.commenting-context section header h5 {
color: #B4B4B3;
margin-top: 0px;
}
.commenting-context section header h5 .topic {
color: #000;
font-weight: 700;
}
.commenting-context .comment-gallery {
display: none;
}
.commenting-context .comment-gallery .comment {
margin-left: 10px;
}
.commenting-context .comment-gallery .comment:first-child {
margin-top: 15px;
}
.commenting-context .comment-gallery .comment header {
padding-bottom: 10px;
}
.commenting-context .comment-gallery .comment header .author {
margin-right: 5px;
font-weight: 700;
}
.commenting-context .comment-gallery .comment header .author.system {
color: #ccc;
}
.commenting-context .comment-gallery .comment header .title {
margin-right: 5px;
}
.commenting-context .comment-gallery .comment header .datetime {
color: #B4B4B3;
}
.commenting-context .comment-gallery .comment p {
font-size: 12px;
margin-top: 10px;
padding: 5px;
inline-size: 400px;
}
.commenting-context .working-status {
border: 1px solid #E7E2E2;
border-radius: 5px;
padding: 10px;
}
.commenting-context .working-status img {
height: 50px;
}
.commenting-context .working-status p {
color: #09347a;
font-size: 20px;
margin-top: 10px;
}
<!-- Comment Widget -->
<div class="commenting-context" data-context-id="0" data-context-fullname="">
<!-- Comment Header -->
<section>
<header class="clearfix">
<h5 class="pull-left">Comments for <span class="topic"></span></h5>
</header>
</section>
<!-- Comment Gallery -->
<section class="comment-gallery"></section>
<!-- Working Message -->
<div class="working-status">
<center>
<img src="/Content/Images/green-working-spinner.gif" />
<p>Working</p>
</center>
</div>
</div>
<!-- Comment -->
<article class="comment" data-id="0" data-commenting-id="0" data-user-id="0" data-is-system-comment="false">
<header class="clearfix">
<span class="datetime"></span>
<div class="pull-right">
<span class="author text-right"></span>
<span class="title text-right"></span>
</div>
</header>
<p></p>
<hr />
</article>
VISUAL:
So, often for UX purposes many third party data tables will apply a white-space: nowrap to a cells contents to apply an ellipsis with a hover tooltip to save on screen real estate in cases with long content strings (or sometimes they'll toggle the table-layout property on the table itself from auto to fixed for other scenarios. Either can effect content strings in various cases.
In this case a definition of white-space: nowrap is apparently applied accompanied by the line-height restriction you identified. So by overriding these properties to allow the wrapping then the cells content will in invoke the default overflow and word-break definitions to allow the user agent rendering it to perform like a paragraph would normally behave.
Glad you got your remedy!
Use a mix of max-width, and max-content.
Type into this snippet to see how it works.
$("input[type='text']").keyup(function ()
{
$("#msg")[0].innerHTML = $("input[type='text']")[0].value;
});
#limit {
width: 300px;
height: 100px;
border: 2px solid black;
padding: 2px;
}
#msg
{
width: max-content;
max-width: 98%;
border: 2px solid black;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id = "limit">
<div id = "msg">
</div>
</div>
<input type = 'text'>
use position property in css
Position:relative;

Set hover on the link inside a class

I'm trying to set a :hover for a link inside a class. At first I tried
.link{
color: #e62739;
}
I saw past discusssion and try the solution proposed
.opener a.link:hover {
color: #e62739;
}
but it didn't work. Im'not sure to know where is my mistake.
.link{text-decoration:none; color:white;}
.opener a.link:hover {
color: #e62739;
}
.row {
display: flex; /* equal height of the children */
}
.col {
flex: 1; /* additionally, equal width */
padding: 1em;
border: solid;
}
div {font-family:'Varela Round';
}
.opener {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border: 1px white solid;
}
.benefits {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-decoration: none;
display: inline-block;
font-size: 16px;
width:300px;
}
a {
text-decoration: none;
}
#upbutton {
border: 1px dotted white;
}
<div class="row">
<div class="opener col" style="padding-left: 10px;padding-right: 10px;"><a class="link" href="www.google.com" name="1" onclick=" show('1');" style="color: white;font-size: 14px;">SOCIETES: 400</a>
<div class="benefits" id="b1" style="display: none; color: white; font-size: 14px;">Part SBF 120 : 120<br />
Part Filiales +100M€: 280
<div id="upbutton"><a onclick=" hide('1');">fermer</a></div>
</div>
</div>
The issue is the inline styling you've got on the link: color: white;.
This is taking priority over any styling you're adding in your CSS file. Removing that from the inline styling allows the hover color to work.
If you need the white color by default add it to the stylesheet rather than inline. For example:
.link {
color: white;
}

Change div height when tab is selected

I have a tabbed content that has 4 tabs and in each there are going to be two divs that make up the border design. The problem that I'm running into is that I have no idea how to animate the divs to change height when the tab they're located in is selected. I have a fiddle for reference and the markup is below.
HTML
<div class="container">
<ul class="tabs">
<li class="tab-link current" data-tab="tab-1" id="welcome_selector">Welcome</li>
<li class="tab-link" data-tab="tab-2">Tab Two</li>
<li class="tab-link" data-tab="tab-3">Tab Three</li>
<li class="tab-link" data-tab="tab-4">Tab Four</li>
</ul>
<div class="tabcontentcontainer">
<div id="tab-1" class="tab-content current"> <div class="bordertop_animate"> </div>welcome tab will be empty, save for the borders <div class="borderbottom_animate"></div></div>
<div id="tab-2" class="tab-content"><div class="bordertop_animate"></div> tab 2 content<div class="borderbottom_animate"></div> </div>
<div id="tab-3" class="tab-content"><div class="bordertop_animate"></div> tab 3 content<div class="borderbottom_animate"></div> </div>
<div id="tab-4" class="tab-content"><div class="bordertop_animate"></div> tab 4 content<div class="borderbottom_animate"></div>
</div>
</div>
</div>
CSS
.container {
width: 1000px;
min-height: 400px;
margin: 0 auto;
}
ul.tabs {
margin: 0px;
padding: 0px;
list-style: none;
background: #000;
vertical-align: middle;
font-weight: 400;
color:#FFF;
text-align: right;
text-transform: uppercase;
font-size: 8px;
letter-spacing: 0.6px;
}
ul.tabs li {
background: #000;
vertical-align: middle;
font-weight: 400;
color:#FFF;
text-align: right;
text-transform: uppercase;
font-size: 8px;
letter-spacing: 0.6px;
display: inline-block;
padding: 55px 15px 55px 15px;
cursor: pointer;
}
ul.tabs li.current {
background: #000;
color: #FFF;
}
#welcome_selector {
float: left;
padding-left: 128px;
}
.tabcontentcontainer {
height: 400px;
width: 1000px;
background: url(http://placehold.it/1000x400) #000;
position: relative;
}
.tab-content {
display: none;
background: rgba(0, 0, 0, 0.0);
padding: 15px;
}
.tab-content.current {
display: inherit;
}
.bordertop_animate {
position: absolute;
height: 38px;
width: 966px;
border-top: 2px solid #FFF;
border-right: 2px solid #FFF;
border-bottom: 0px solid #FFF;
border-left: 2px solid #FFF;
}
.borderbottom_animate {
position: absolute;
bottom: 15px;
height: 38px;
width: 966px;
border-top: 0px solid #FFF;
border-right: 2px solid #FFF;
border-bottom: 2px solid #FFF;
border-left: 2px solid #FFF;
}
JS
$(document).ready(function(){
$('ul.tabs li').click(function(){
var tab_id = $(this).attr('data-tab');
$('ul.tabs li').removeClass('current');
$('.tab-content').removeClass('current');
$(this).addClass('current');
$("#"+tab_id).addClass('current');
})
})
I'd like for the first tab to keep current divs height which is 38px, however I'd like the other 3 tabs to have theirs at a height of 185px- but for the height to grow from 38px to 185px when the tab is selected. The animation would be similar to if the divs had a :hover css selector applied with a 0.5s transition, except it would happen when the tab is selected, not on mouseover.
Sorry if this isn't detailed or specific enough, this is my first time posting a question/and dealing with jquery.
Here is a jquery solution to your problem, just in case you need it.
JS fiddle: http://jsfiddle.net/nPAhw/
html
<ul>
<li id="tab1">Tab One</li>
<li id="tab2">Tab Two</li>
</ul>
<div id="tabone">Tab one</div>
<div id="tabtwo">Tab Two</div>
css
#tabone{
width:200px;
height:38px;
border:solid blue;
margin:10px;
}
#tabtwo{
width:200px;
height:38px;
border:solid black;
margin:10px;
}
#tab1:hover{
cursor:pointer;
}
#tab2:hover{
cursor:pointer;
}
jquery / javascript
$('#tab1').click(function(){
var h = $('#tabone').height();
if(h < 185){
$('#tabone').animate({height:'185px'});
$('#tabtwo').animate({height:'38px'});
}
else $('#tabone').animate({height:'38px'});
});
$('#tab2').click(function(){
var h = $('#tabtwo').height();
if(h < 185){
$('#tabtwo').animate({height:'185px'});
$('#tabone').animate({height:'38px'});
}
else $('#tabtwo').animate({height:'38px'});
});
You would want to use the Jquery Animate method.
This method can perform animation effects on any numeric CSS property, like for example, height, which is what you want to achieve.
$( ".element-class" ).animate({
height: "185px"
}, 500);

Flowchart with CSS/HTML

Currently I'm trying to make a flowchart, this is the code I've got so far:
#flowchart {
width: 580px;
text-align: center;
font-family: sans-serif;
font-size: .8em;
margin: auto;
}
#flowchart a {
display: block;
color: white;
text-decoration: none;
background-color: #2F41B1;
padding: 2em 1em;
}
#flowchart a:hover {
color: #111;
background-color: #EFA707;
}
.no1 {
width: 390px;
border: 1px solid #444;
margin: 0 auto;
}
.line1 {
width: 1px;
height: 20px;
background-color: #000;
margin: 0 auto;
}
.clear {
clear:both;
}
<div id="flowchart">
<div class="no1"><a href="http://example.com/page1">Step 1:
Blah blah blah, do this.</a></div>
<div class="line1"></div>
<div class="no1"><a href="http://example.com/page2">Step 2:
Then this and that.</a></div>
<div class="line1"></div>
<div class="no1"><a href="example.com/page3">Step 3:
Now finally go here and there.</a></div>
</div>​
How can I make only the headings ("step x") for each section be bold and larger? (and not the content after, "blah blah then this etc")
Also, how can I make rounded corners instead of sharp edges?
i made a quick fiddle of what you wand dude. http://jsfiddle.net/jalbertbowdenii/NY973/1/
To make the Step x styled differently, you need to wrap it in a <span class="flowchartHeader">...</span> tag, then add this to your CSS:
.flowchartHeader {
font-size: 1.2em;
font-weight: bold;
}
As for rounding, add border-radius: 6px to .no1.
Use this to generate the round corners css for you border-radius.com
.myClass{
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
}
.no1
{
width: 390px;
border: 1px solid #444;
margin: 0 auto;
border-radius:5px; //add this
}

Box-shadow shows around block not around text when applying it to h2

HTML:
<div class="div1">
<h2>Set RSVP & Check in</h2>
<p>
Set RSVP to remind all events you plan to go.
</p>
</div>
CSS:
.div1 {
float: left;
margin: 0 20px 0 0;
padding: 0;
width: 300px;
height: 156px;
}
.div1 h2 {
color: #fff;
font-size: 24px;
font-weight:bold;
box-shadow: 1px 1px 0 black;
}
And border appears like "table border" not the border on text:
http://screencast.com/t/OrFfBL9MK
I think you are confusing box-shadow with text-shadow.
Try this:
.div1 h2 {
color: #fff;
font-size: 24px;
font-weight:bold;
text-shadow: #000000 1px 1px 0px;
}