This is my first question in the StackOverflow. So, please let me know if I didn't follow a rule of posting a question well. :)
[Problem 1]
I tried to solve my issue of having texts centered in circles by reading the following posts:
However, I couldn't solve my issue. I would like to move texts in circles into the middle of the circle to make the texts horizontally & vertically in the center of the circles.
[Problem 2]
Hidden circles show up after clicking the "test" button. However, the circles do not disappear after clicking the button again.
If anyone can give me an advice, I would really appreciate it! :)
Solved!
- This question is not a duplicate, because I wanted to center text while using translate() and got confused with using between "fadeToggle()" and ":hidden with fadeIn()".
$(document).ready(function() {
$('#test').click(function() {
$(".options:hidden").fadeToggle();
});
});
body {
font-family: 'Poor Story', sans-serif;
}
#test {
cursor: pointer;
display: block;
text-align: center;
position: absolute;
display: flex;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.options {
background: #f7f7f5;
display: none;
text-align: center;
vertical-align: middle;
position: absolute;
width: 100%;
left: 50%;
top: 50%;
border-radius: 50%;
border-style: solid;
border-color: #F3C78D;
width: 60px;
height: 60px;
font-size: 12px;
}
.options span {
color: #000000;
text-align: center;
vertical-align: middle;
position: absolute;
width: 100%;
}
#option1 {
transform: translate(-100%, -150%);
}
#option2 {
transform: translate(-160%, -40%);
}
#option3 {
transform: translate(-50%, 50%);
}
#option4 {
transform: translate(60%, -40%);
}
#option5 {
transform: translate(15%, -150%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap 4.1.x -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Poor+Story" rel="stylesheet">
</head>
<body>
<div class="container">
<button type="button" class="btn btn-outline-success" id="test">test</button>
<div class="options" id="option1"><span>Hello<br>World</span></div>
<div class="options" id="option2"><span>Goodbye</span></div>
<div class="options" id="option3"><span>How<br>are<br>you?</span></div>
<div class="options" id="option4"><span>Fine</span></div>
<div class="options" id="option5"><span>Okay</span></div>
</div>
</body>
<footer>
<!-- Bootstrap 4.0 : jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js" integrity="sha384-o+RDsa0aLu++PJvFqy8fFScvbHFLtbvScb8AjopnFD+iEQ7wo/CG0xlczd+2O/em" crossorigin="anonymous"></script>
<script type="text/javascript" src="index.js"></script>
</footer>
</html>