I am new in learning jquery and making my own website. This is my fiddle JSFIDDLE. When you hover a new div shows up with some text. But the text is going out of that div. I want that text within the new div. I dont know why that is happening. I know this is a silly question but i spent like more than an hr getting it right.
The code
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="example.js"></script>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="box">
<h2 id='name'> Karan Shah </h2>
<div id='innerbox'><span><h4 id='emptyInfo'></h4></span><div>
<script>
$('#innerbox').hide();
</script>
</div>
<script>
$('#name').css('color','black');
$('#name').css('text-align','center');
$(document).ready(function () {
var originalText = $('#name').text();
var tOut;
$("#box").hover(
function () {
tOut = setTimeout(function(){
$('#innerbox').show('slow',function(){
$('#emptyInfo').fadeOut(400, function () {
$(this).text('Welcome to my website').slideDown().css('text-align','center');
});
});
},1000);
},
function(){
clearTimeout(tOut);
$('#innerbox').hide('slow',function(){
$('#emptyInfo').hide('slow');
});
}
);
});
</script>
</body>
</html>
the CSS
#box {
background-color: lightgrey;
width: auto;
padding: 25px;
margin: 25px;
}
#emptyInfo{
font-size: 150%;
}
#innerbox {
background-color: white;
width: auto;
height: 30px;
border-radius: 10px;
border : 1px;
border-style: solid;
border-color: darkgrey;
}
` margin: `#emptyInfo { margin: 0; }`.
– emmanuel Dec 17 '14 at 18:20