Long heading text results in empty gap - css

Currently my movie heading code looks like this:
.moview-info h1 {
color: #fff;
margin: 0 0 15px 0;
font-weight: normal;}
And I tried adding these lines:
display:block;
word-wrap: break-word;
max-width: 700px;
It fixes the issue partly, because when I'm shrinking my browser window, the star rating causes the heading go up and not overlap. Is there any way to fix this issue besides not displaying star rating?
Rating star code:
position: absolute;
left: 50%;
margin-left: -70px;
font-size: 130px;
width: 140px;
height: 140px;
line-height: 140px;
short title long title

This styling is usually done with { display: flex; justify-content: space-between; } as the CSS of the parent element of the title and the star. Demo below (the JS is just to animate the text):
const titleElt = document.querySelector('#title');
let titleValue = '';
setInterval(() => {
if (titleValue.length>70) {
titleValue = '';
} else {
titleValue += Math.floor(10*Math.random());
}
titleElt.innerHTML = titleValue;
}, 100);
body {
margin: 0;
font-size: 2em;
}
header {
display: flex;
justify-content: space-between;
width: 100%;
}
#title {
width: 90%;
word-wrap: break-word;
}
#star {
width: 10%;
}
<header>
<div id="title"></div>
<div id="star">⭐</div>
</header>

Related

CSS - onhover pulls down div vertically when page width is small

I am working on a site where there is an info icon next to the logo in the center of the page. When hovering over the info icon, a text box displays. For some reason, when the screen width is shorter than around 1300px, the entire logo as well as the info box is pulled down vertically. Not sure what aspect of onhover could be causing this.
I tried to manually move down the info icon with media queries but that is not a good way of doing it.
Here is react component:
function HomeContent() {
return (
<>
<div className="center-div">
<img src={tenGreenLogo} className="ten-green-logo" alt=""></img>
<div className="info-div">
<img src={infoIcon} alt="" className="info-icon"></img>
<p className="hidden-info">
The 10Green Score indicates the health of your environment using a
number from 0 to 10. The higher the score, the healthier your
environment.
<br></br>
<br></br>
Factors that can reduce your score include unhealthy air quality
readings and poor environmental monitoring.
</p>
</div>
</div>
<Globe />
</>
);
}
export default HomeContent;
and here is CSS for that component:
.center-div {
display: flex;
justify-content: center;
align-items: center;
padding-top: 7rem;
padding-bottom: 0rem;
scroll-behavior: smooth;
}
.ten-green-logo {
max-width: 40%;
animation: transitionIn 1s;
padding-right: 1rem;
}
.info-div {
width: 2rem;
margin-top: auto;
margin-bottom: 0;
}
.info-icon {
width: 2rem;
animation: transitionIn 1s;
}
.hidden-info {
display: none;
}
.info-icon:hover + .hidden-info {
display: block;
position: relative;
background-color: white;
padding: 0.6rem;
border-radius: 5%;
width: 20rem;
font-size: 80%;
right: 7.5rem;
top: 10.5rem;
}
.info-icon:hover {
position: relative;
top: 10.6rem;
}
#keyframes transitionRight {
from {
transform: translateX(0rem);
}
to {
transform: translateX(2rem);
}
}
#keyframes transitionIn {
from {
opacity: 0;
transform: translateY(4rem);
}
to {
opacity: 1;
transform: translateY(0rem);
}
}
Any help would be greatly appreciated.
use this style, you have to use position absolute on hidden-info
.info-div {
position: relative;
}
.hidden-info {
display: none;
position: absolute;
background-color: white;
padding: 0.6rem;
border-radius: 5%;
width: 20rem;
font-size: 80%;
right: 7.5rem;
top: 10.5rem;
}
.info-icon:hover + .hidden-info {
display: block;
}

How to style <details> and <summary>?

Just found out about and tags. Default gives out a very crude style. I had success using the ::marker Pseudo Element to remove the default marker, but don't know how to put it on the right side. Used the ::after Pseudo Element but can't animate it (Rotate 180deg or scale it) when the summary "opens". Is there a proper way to do it? Or did I miss anything with my method? Thanks.
PS: Since I am a newb, I don't know how to get the Google icon font to the codepen. However, you will see what I tried to do with the expand_arrow icon.
* {
box-sizing: border-box;
margin: 0px;
padding: 0px;
}
.thing {
background-color: cadetblue;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.new_game {
font-size: 3rem;
}
.what_is_question {
background-color: cornflowerblue;
cursor: pointer;
}
.what_is_question[open] {
background-color: darkmagenta;
}
.what_is_question {
font-size: 5rem;
}
.question_title {
position: relative;
}
.question_title::after {
content: url(./images/expand_more_black_24dp.svg);
}
.what_is_question[open] .question_title::after {
transform: rotate(180deg);
}
.question_title::marker {
content: none;
}
.answer {
background-color: darkkhaki;
font-size: 3rem;
padding-left: 3.5%;
}
<div class="thing">
<h1 class="new_game">QnA</h1>
<details class="what_is_question">
<summary class="question_title">What is the question?</summary>
<p class="answer">The question is the answer.</p>
</details>
</div>
https://codepen.io/consig1iere/pen/bGWXRMW
The problem is that you can't apply transforms to elements with display: inline.
So add display: inline-block; to your .question-title
.what_is_question[open] .question_title::after {
display: inline-block;
transform: rotate(180deg);
}

Text/Link appear on hover

I tried the solutions here and here with no luck. My css file as it is:
.JFK {
position: relative;
left: 250px;
height: 200px;
width: 200px;
bottom: -45px;
background-image: url(https://media-cdn.tripadvisor.com/media/photo-s/03/9b/2d/f2/new-york-city.jpg);
line-height: 200px;
text-align: center;
}
.JFK a p{
position: relative;
top: -130px;
display: none;
}
.JFK a:hover p{
display: block;
}
.JFK:hover{
opacity: 0.6;
display: block;
}
My html:
<div class = "JFK">
<p>JFK</p>
<p>to</p>
<p>from</p>
</div>
I'm trying to have links appear at the bottom of the image upon hover. The solutions in previous posts have not worked. With my current setup, I cannot see "TO" or "FROM" at all when I load the page.
The hover should be on the .JFK not the .JFK a When you hover over the .JFK it should make the .JFK a p visible.
.JFK:hover a p {
display: block;
}
Here is a link to a jsfiddle with the change: https://jsfiddle.net/efv8ch70/
Hope this helps
.JFK {
position: relative;
top: 50px;
left: 250px;
background-image: url(https://media-cdn.tripadvisor.com/media/photo-s/03/9b/2d/f2/new-york-city.jpg);
}
.JFK,
.JFK > p {
height: 200px;
width: 200px;
}
.JFK > p {
text-align: center;
display: flex;
align-items: center;
justify-content: center;
margin: 0;
}
.link-wrapper {
display: none;
}
.JFK:hover .link-wrapper {
display: block;
}
<div class="JFK">
<p>JFK</p>
<div class="link-wrapper">
<span>to</span>
<span>from</span>
</div>
</div>
There are lots of ways to solve this problem. This solution is just an example. The actual paragraph has the same hight as the .JFK so it pushes the .link-wrapper down to exactly the spot you want in the normal flow. Hope this helps or gives you some ideas.

Align div next to two other grouped div's

How can I get that yellow box aligned like on the picture? I tried some stuff with table cells but it kinda destroyed everything. I also played a bit with the float conditions but the results were horrible too. Can you help me?
Here's my code:
HTML
<div class="job_board">
<div class="job_box">
<span class="job_title_working_field"> <!-- Just made that span for grouping but it's unnecessary. -->
<div class="job_title"><h1>Product Development <span class="light">(m/w)</span></h1></div>
<div class="working_field">Fahrzeugtechnik · Mechatronik · Maschinenbau</div>
</span>
<div class="slide_button"></div>
</div>
</div>
CSS
.light {
font-weight: normal;
}
.job_box {
width: 100%;
padding: 30px 50px;
background-color: #082730;
color: white;
text-align: center;
display: table;
}
.working_field {
font-weight: bold;
margin: 0;
font-size: 0.8em;
}
span.job_title_working_field {
table-cell;
}
.slide_button {
position: absolute;
width: 50px;
height: 100%;
background: yellow;
display: table-cell;
}
JSFiddle
Since .slide_button is within an element, you would simply relatively position the parent element:
.job_box {
position: relative;
width: 100%;
padding: 30px 50px;
background-color: #082730;
color: white;
text-align: center;
display: table;
font-family: "Helvetica", sans-serif;
}
And then absolutely position the yellow .slide_button element at the top/right - relative to the parent.
UPDATED EXAMPLE HERE
.slide_button {
position: absolute;
right: 0;
top: 0;
width: 50px;
height: 100%;
background: yellow;
}
If you look at the above example, you will notice that a horizontal scrollbar is present. If you want to remove this, use box-sizing:border-box in order to include the padding within the .job_box element's dimension calculations.
UPDATED EXAMPLE HERE
.job_box {
box-sizing:border-box;
-moz-box-sizing:border-box;
}
It's also worth noting that I removed the default 8px margin on the body element.. body{margin:0}
I changed the markup order a little and updated the css
you are combining too many styles: table-cell + absolute + float don't mix well
http://jsfiddle.net/pixelass/3Qqz4/2/
HTML:
<div class="job_board">
<div class="job_box">
<div class="slide_button"></div>
<div class="job_title_working_field">
<div class="job_title">
<h1>Product Development <span class="light">(m/w)</span></h1>
</div>
<div class="working_field">Fahrzeugtechnik · Mechatronik · Maschinenbau</div>
</div>
</div>
</div>
CSS:
* {
margin: 0;
padding: 0;
}
.light {
font-weight: normal;
}
.job_box {
width: 100%;
background-color: #082730;
color: white;
text-align: center;
display: block;
font-family:"Helvetica", sans-serif;
position: relative;
height: 120px;
vertical-align: top;
}
.job_title h1 {
margin: 0;
}
.working_field {
font-weight: bold;
margin: 0;
font-size: 0.8em;
}
.job_title_working_field {
padding: 30px 50px;
}
.slide_button {
width: 50px;
height: 100%;
background: yellow;
float: right;
}

Openlayers Map is shown only if the CSS contains a syntax error

I'm trying to create a webpage that shows an almost fullscreen map. The map should fill the space between header and footer. This is the code I have so far:
HTML:
<header>
<div class="mainBodyElement" id="header">
</div>
</header>
<div id="content">
<div id="map"></div>
</div>
<footer>
<div class="mainBodyElement" id="footer">
<p>© 2013</p>
</div>
</footer>
Javascript:
var map;
function initOpenLayers() {
/* Example code from openlayers.org */
map = new OpenLayers.Map({
div: "map",
layers: [
new OpenLayers.Layer.OSM("OSM (without buffer)"),
new OpenLayers.Layer.OSM("OSM (with buffer)", null, {
buffer: 2
})],
controls: [
new OpenLayers.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
}),
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.Attribution()]
});
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
}
$(document).ready(function () {
initOpenLayers();
});
CSS:
<!-- <> -->
* {
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
}
html, body {
width: 100%;
max-width: 100%;
height: 100%;
max-height: 100%;
}
.mainBodyElement {
position: absolute;
width: 100%;
overflow: hidden;
}
#header {
top: 0;
left: 0;
height: 50px;
background-color: #2CA07A;
color: white;
}
#footer {
top: auto;
bottom: 0;
height: 34px;
width: 100%;
overflow: hidden;
background-color: #2CA07A;
color: white;
}
#content {
position: fixed;
top: 50px;
left: 0;
right: 0;
bottom: 34px;
overflow: auto;
background: #EEE;
}
/* login
----------------------------------------------------------*/
#login {
float: right;
display: block;
font-size: .85em;
margin: 0 0 10px;
text-align: right;
}
#login a {
background-color: #d3dce0;
margin-left: 10px;
margin-right: 3px;
padding: 2px 3px;
text-decoration: none;
}
#login .email {
background: none;
margin: 0;
padding: 0;
color: #CCCCCC;
}
#login ul {
margin: 0;
}
#login li {
display: inline;
list-style: none;
}
#map {
width: 100%;
height: 100%;
}
I've created a fiddle (http://jsfiddle.net/palpitation/MUKRe/3/) which shows a working example (it'll fill when you zoom in which is alright), but it also shows my question:
The first line of the CSS is:
<!-- <> -->
This is invalid syntax because it's in a CSS block, but if I omit it, the map won't show. Even if I omit the <> part of this line only, the map won't show anymore. I'm at a loss and really don't know how to keep it working without this strange line of code. If I keep the line though, Visual Studio keeps bugging me about invalid syntax. I don't like to have invalid syntax to keep my code running, so I hope that someone can tell me what I'm doing wrong here.
Your <!-- <> --> is invalidating and causing your rules in the first set of curly brackets to break. This css,
* {
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
}
along with your weird line of code should be removed, and everything should be fine. Specifically, it is the * {overflow: hidden;} which is the culprit.
overflow: hidden;
is the problem

Resources