CodePen Project
If you visit the page you can see that the list(ul) is simply listed vertically
I want to list season 1,2,3 completely seperately in three columns (like down below)
S01E01 S02E01 S01E01
S01E02 S02E02 S01E02
S01E03 S02E03 S01E03
And the other problem is the width for the list, in the the site some of the items of the list is partially in the next line.
S01 E03 ยท The Would-Be Prince of
Darkness
like this(like in the web)
it gets affected by the width
.tv {
list-style: none;
width: 300px;
border-radius: 2px;
}
when I set width higher long lines are complete but few short items are displayed in the same line
I need to fix those two problems
display: grid;
grid-template-columns: 20% 20% 60%;
Dude Try putting every 'ul' including every season in a div and the give div this property
div{
float:left;
width: 30%;
}
OR maybe look at this test code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html, body{
font-family: "Verdana";
}
div{
float:left;
width: 30%;
}
</style>
</head>
<body>
<div><h1>HELLO</h1></div>
<div><h1>HELLO</h1></div>
<div><h1>HELLO</h1></div>
</body>
</html>
Related
I try to create a CSS-only IMG-Tooltip generated from an attribute value.
I tried the following code
<img src="blabla.jpg" data-caption="this is my caption" />
and the CSS-Code:
img {
position: relative;
}
img:after {
content: attr(data-caption);
position: absolute;
bottom: 2em;
left: 2em;
z-index: 2
}
Such a way is no problem with div containers. But how can I get this working on images?
Thank you,
Thomas
Well you have multiple ways to create a tooltip using CSS but here is a small example to create tooltip for image.
In below example I have use title attribute of html which also works kind of similar.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Shaqi_jrvej.jpg/1200px-Shaqi_jrvej.jpg" title="imgae">
</body>
</html>
You'll find more useful answer here : Answers
Let me know if you find this code helpful.
Is there a way to be able to have HTML / CSS just warp the lines on the same line?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.MYDIV {
overflow-x: auto;
white-space: pre-line;
border: 1px solid #cccccc;
height: auto;
width: 320px;
}
</style>
<body>
<div class="MYDIV">
Look I really just want to be able to write this like this in html.
And have this be on the same line in the browser and wrap. I know
it's weird but it would make my life easier.
</div>
</body>
</html>
What the HTML CSS gives me
What I want without having to write everything in one line.
If this is imposable I can accept that.
Remove white-space: pre-line from your code and it will give you the desired output.
Because when using pre-line lines are broken at newline characters, at <br>, and as necessary to fill line boxes.
Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
Also add padding-top: 10px; for the space above the content (I spotted this on the screenshot).
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.MYDIV {
overflow-x: auto;
/*white-space: pre-line;*/
border: 1px solid #cccccc;
height: auto;
width: 320px;
}
</style>
<body>
<div class="MYDIV">
Look I really just want to be able to write this like this in html.
And have this be on the same line in the browser and wrap. I know
it's weird but it would make my life easier.
</div>
</body>
</html>
The solution has already been given, I just want to mention one thing. It's always a good practise to use a paragraph tag for this sort of writing. That will adjust many issues by itself.
So remove white-space: pre-line; and use
<p class="MYDIV">
Look I really just want to be able to write this like this in html.
And have this be on the same line in the browser and wrap. I know
it's weird but it would make my life easier.
</p>
This is surely a good practise to write HTML codes.
I am using Codepen and the textbox should be in the center with a smaller width, but no matter what I add to the .box area of the CSS, it doesn't respond. I can confirm that this isn't a web browser issue as I've tried both Google and Brave
You are using html tag in css. It won't work anymore. Style tag is used when you want to write css in your html file internally. Like this -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 10%;
text-align: center;
}
</style>
</head>
<body>
</body>
</html>
But if you write css in a separate file, you needn't use the <style></style> tag. Just write the css like this -
.box {
width : 10%;
text-align : center;
}
And codepen gives you the ability to write HTML, CSS, and javascript separately. So, don't use tag.
I have built a WebGL game using Unity, and I put it on a domaine, everything is working fine, but I want to center the game screen in the webpage like in thisimage.
here is the index.html code:
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Game Title</title>
<script src="Build/UnityLoader.js"></script>
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "Build/WebGL.json");
</script>
</head>
<body style="background-color:black;">
<div id="gameContainer" style="width: 1024px; height: 576px; margin: auto "></div>
</body>
</html>
I found the answer for this i just added a this style to head
<style>
.container {
width: 80%;
margin: 0 auto;
padding: 20px;
}
</style>
and I put the div gameContainer inside another div with the style above. Not sure if this is the right solution, but it works
I encountered a similar issue, my WebGL build was suddenly left aligned. Found out that I mistakenly changed the WebGL template setting on Player Settings from Default to Minimal. Default is centered aligned.
i'm running some basic beginner tutorials in order to learn how to properly run html. I've come to the portion where i'm using a div tag in css to center the content. However, once i open the test page, everything stays locked to the right of the browser. I've been scouring the forums for any solution and nothing seems to fix the issue. Tested in Chrome and IE.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>My First Website</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div>
<h1> My Website </h1>
<p>Learn more about me.</p>
<img src="img/lady.jpg" alt="skyrim">
<h2>My New Section </h2>
</div>
</body>
</html>
Here's the CSS:
a {
color: red;
text-decoration: none;
}
h1 {
font-family: sans-serif;
}
div {
width: 500px;
margin: 0 auto;
background: red;
text-align: center;
}
You have no Doctype. This puts you in Quirks mode (the land of incompatibility).
Add one as the very first thing in your document.
<!DOCTYPE html>
It looks fine in my end:
http://jsfiddle.net/Riskbreaker/JH7NK/
If you mean that extra space you have vertically on top its your h1.
I edited to show you:
div h1 {margin: 0}
You need to add a DOCTYPE. This is an example of the HTML5 DOCTYPE
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
HTML here
</body>
</html>