I have recently started learning html and css but I cant seem to figure out which approach is the best to get a certain task done .
I want to create a box at the top of the page that covers the whole screen from left to right at a certain height. And inside the box I'd like to have a text which properties can be controlled separately from the box .
So if have created 2 div and assigned 2 ID , one for the text and one for the box . And used CSS to modify the properties of each .
Am I working right so far ?
You have to add any tag containing the text. This is the best solution.
Example:
<header>
<div class="content">
<p>some text</p>
</div>
</header>
And the CSS
header { width: 100%; padding: 20px 0; }
header .content { width: 1000px; margin: auto; }
header .content p { font-size: 22px; color: #000; }
You are correct.
But If you uses classes you will be able to re-use them multiple times on the same page without any conflicts.
When you come to style anything on a page, you will use the wrapping element and/or class/id to control how it is displayed.
.outer {
background: yellow;
padding: 3em 0;
}
.outer.red {
background: red;
height: 60px;
}
.inner {
background: green;
width: 500px;
margin: 0 auto;
color: #fff
}
.inner p {
border-bottom: 2px solid blue;
}
<div class="outer">
<div class="inner">
<p>Did he speak to you? Would you just answer? What things? What people? A month ago, Gus was trying to kill both of us. And now, he pulls you out of the lab and employs you as... what... a, an assistant gunman? A tough guy? Does that make any sense
to you? He says he sees something in you. What kind of game is he playing. Does he think you're that naïve? He can't truly think that you'd forget... let alone Gale, let alone Victor... and all the horror that goes along with all of that.</p>
<p>It's enough. This is still the best way. You go after him with a gun, you'll never get out of it alive. But with this... you slip it into his food or drink, there shouldn't be any taste or smell... thirty-six hours later... poof. A man his age, working
as hard as he does... no one will be surprised. Mike can have his suspicions, but that's all they'll be. Please, one homicidal maniac at a time.</p>
</div>
</div>
<div class="outer red">
</div>
<div class="inner">
<p>Did he speak to you? Would you just answer? What things? What people? A month ago, Gus was trying to kill both of us. And now, he pulls you out of the lab and employs you as... what... a, an assistant gunman? A tough guy? Does that make any sense to
you? He says he sees something in you. What kind of game is he playing. Does he think you're that naïve? He can't truly think that you'd forget... let alone Gale, let alone Victor... and all the horror that goes along with all of that.</p>
<p>It's enough. This is still the best way. You go after him with a gun, you'll never get out of it alive. But with this... you slip it into his food or drink, there shouldn't be any taste or smell... thirty-six hours later... poof. A man his age, working
as hard as he does... no one will be surprised. Mike can have his suspicions, but that's all they'll be. Please, one homicidal maniac at a time.</p>
</div>
Related
I am working on this task where I need to put the divs in the required positions. The final result should be this:
.
I have the following code:
HTML:
<div class="activity">
<h2>Activity 5</h2>
<section class="hint"><input type="checkbox" > <h3>Hint 5</h3><i></i><div><p>Grid is <strong>not</strong> the right way to do this. In fact there is only one way to really do that...and that is with float. Remember that we float the thing we want the text to wrap around. Also remember to start by making all the shapes the right size and shape.</p><h4>Properties used:</h4><ul><li>float: left;</li></ul></div></section>
Wrap the text around the square like in this image. This is one case where Grid is NOT the right way to solve this one and will in fact make it harder if you try to use it!
<div class="content5" >
<div class="red5" ></div>
<div class="green5" ></div>
<div class="yellow5">Step 01: Continue creating the main page for your chosen web site by modifying the CSS file you created in week 9's Adding Classes and IDs to Your Website assignment. This week, you will position all of the content on your main page using the CSS positioning techniques taught in KhanAcademy. When you are done, your webpage layout should reflect what you outlined in the wireframe you designed in the assignment Your Own Site Diagram and Wireframe in week 3. <br />
If you have changed your mind on how you want the content of your main page laid out, take an opportunity to update your wireframe before completing this assignment (it is much easier to experiment with different layouts in a wireframe than it is to do so by modifying the CSS). Also, if you find that you are having trouble with using CSS positioning, feel free to review the concepts at the learn layout site: http://learnlayout.com/. You should be able to apply these principles to your site. For futher help, refer back to the Max Design site used in the beginning of the course for an example of how to implement your site design.</div>
<div class="blue5"></div>
</div>
</div>
CSS:
.content5 {
/* This is the parent of the activity 5 boxes. */
position: relative;
}
.red5 {
width: 100%;
height: 100px;
background-color: red;
}
.green5 {
width: 100px;
height: 100px;
background-color: green;
position: absolute;
}
.yellow5 {
width: 100%;
height: auto;
background-color: gold;
}
.blue5 {
width: 100%;
height: 100px;
background-color: blue;
}
The code I have so far looks like this: I have tried a couple of things to make the text appear next to the div but they haven't worked. The HTML should not be modified. And I need to use CSS for this task, not bootstrap or something else. Thanks!
Add this to .green5 would work.
I've tried it and it actually works well.
.green5 {
width: 100px;
height: 100px;
background-color: green;
float: left;
}
I want to linebreak a WordPress site title over two lines at a specific point in the text.
Due to the WordPress content filter 'wpautop', the <br> tag (aka <br/> or <br />) is disabled seemingly site-wide. I understand the motive behind disabling the tag, but I'd like to know what is deemed the 'correct' way of line breaking with CSS in lieu of the traditional tag.
To clarify, I want to achieve this without the <br> tag:
This is a<br>Site Title
EDIT: Ideally I would achieve this functionality without having to hard-code the site title with markup so users are still able to amend the title in the admin setting. Is there a way to wrap after nth word or nth char with CSS for example?
So the answer is, at this point in time there's no simple way to allow the use of a line break in a WP title. I ended up writing my own theme which was something I was trying to avoid, hence the question.
A little context: Many site logo's have text 'baked in' to the image and then handle the SEO side of things with metadata/attributes. I wanted to allow users to add their own title via a frontend input such as WPs 'customise theme' editor for it then to become part of the logo and an SEO-friendly h1.
My solution for a logo with real text is below. I scrapped the idea of basic user input but this did end up producing a really nice, fully responsive SEO-friendly logo.
a {
text-decoration: none;
font-size: 1.8rem;
}
img {
text-align: center;
padding: 15%
}
#divHeaderLogo {
display: flex;
min-width: 24rem;
}
#divLogoImage {
border-style: dotted;
width: 8rem;
height: 8rem;
}
#divLogoText {
min-width: 16rem;
}
#logoTextLine2 {
font-size: 2.5rem;
}
<div id="divHeaderLogo">
<div id="divLogoImage">
<img src="" alt="Image Placeholder">
</div>
<div id="divLogoText">
<h1>
Here's a Wrapping <div id="logoTextLine2">Logo Title</div>
</h1>
</div>
</div>
My first question so please go easy. I've been stumped on this for a day now and can't work out what the issue is. Essentially I have a div with an ID that i'm adding a background url too..image1 inside the main div. Essentially it's an image that swaps when I hover. I've gone right back to basics and tried this code in a fresh document and it works perfectly. However when I paste the same code in the file i'm trying to work on the image doesn't display. No idea what would be stopping it?
The div id is working. I styled an empty red box to test it out.
The path is correct. I even went as far as to paste the image into my root for the sake of simplicity. Still nothing.
Any help would be appreciated.
html:
<div id="main">
<h1> <!-- something something about us --> </h1>
<p>The Custom House clock struck one. Mr. Fogg observed that his watch was two hours too fast.
Two hours! Admitting that he was at this moment taking an express train, he could reach London and the Reform Club by a quarter before nine, p.m. His forehead slightly wrinkled.</p>
<div id="image1"> </div> <!-- This is the part i'm having trouble with-->
CSS (including all css for #main):
#main h1 {
text-align: center;
padding: 30px 0 0 0;
color: #4b4b4c;
}
#main {height: 685px;}
#main p {
padding: 20px 50px 0 50px;
width: 60%;
margin: 0 auto;
text-align: center;
font-size: 15px;
color: #868686;
}
/* rollover css images */
#image1 {
background: url(contextmap.jpg) no-repeat;
width: 400px;
height: 400px;
}
I haven't added the hover yet because I can't even get the initial image to display, yet everything worked fine in my sample using only this code.
If there's anything i've left out please let me know. Like I said this is my first time posing a question. Thankyou.
You may need to change the file path in your css.
Instead of:
url(contextmap.jpg)
Try:
url(../images/contextmap.jpg)
Images can be replaced for the name of the folder where the jpg is stored.
The URLS in the css are relative to the CSS file, not the HTML file that links it. this should work if you have the image and the CSS in the same folder (or in case of CSS inside a style tag in your HTML file, same folder as your HTML file).
So my footer won't stay down. It just appears on the middle of my page. I bet you've seen this question a lot of times but I really need some help since I've read tons of threads and I've tried the general solution outlined here:
http://matthewjamestaylor.com/blog/keeping-footers-at-the-bottom-of-the-page
I will link my code and hopefully you can notice why the solution doesn't work for me.
HTML:
<!DOCTYPE HTML>
<HTML>
<header>
<title>Heilsa</title>
<link type="text/css" href="stylesheet3.css" rel="stylesheet"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</header>
<body>
<div id="container">
<img id="bordi" src="taka2.png"/>
<div class="menu">
<ul>
<li>Heim</li>
<li>Hollt Mataræði</li>
<li>Reynslusögur</li>
</ul>
</div>
<div id="content">
<div id="block">
</div>
<div id="meginmal">
<h1>Fyrirsögn</h1>
<p>A wall of text is something that is frowned upon in most, actually virtually all Internet societies, including forums, chat boards, and Uncyclopedia. You should not make walls of text because it can get you banned anywhere unless it is a place that encourages walls of text. I highly doubt any place does support something so irritating and annoying, but anything can exist, but not really because unless you are in heaven then that can happen. But no one actually knows that was just a hypothesis, a lame one that is. Actually not really lame. You can create a wall of text supporting site, but you would be hated if you do that, so do not. But you can if you like, but I discourage that. Now on to the actual information of walls of texts. The wall of text was invented when the Internet was invented, but actually it was slow at that time. So whenever it became fast. But there would need to be some free or not free community for people, and that community would be able to have walls of text. But that community probably wouldn't have actually invented the wall of text. So basically, no one except God and Al Gore knows when or where or how the wall of text existed/was invented. Noobs probably invented, but probably not. Who knows. Walls of texts are usually filled with a lot of useless information and junk. Information and junk can be the same, but only if the information is junk or the junk is information. But who cares. The information/junk inside a wall of text are usually related to wherever the wall of text is located, but the best walls of text, which are actually the most irritating, most eye-bleeding ones, are completely random. Walls of text usually make the reader asplode or have their eyes bleed and fall out of their sockets. A number of people can stand it, but not read them. Actually some people can stand and read them. Those people do not have short attention spans. These are boring and patient people who have no life or have all the time in their hands, which are the same, but not really. The punishment of what making walls of text varies of the strictness of the community. But it doesn't really matter. Nobody cares. Walls of texts should be free of links, different font colors, strange characters, which are those other symbols used in society, and capital letters because it ruins the whole purpose of the infamy of walls of texts. It makes them look dumb and weird. Walls of texts are obviously free of huge spaces and outstanding things like capital letters. Of course, paragraphs should never be in a wall of text. Walls of text are known to create nausea, confusion, head explosion, and others. The others being something I can not think of either because I am lazy or if I do not feel like it or I can not actually think of anything. Like what the fuck? That was a rhetorical question right there. What the fuck? You are actually not requesting a satisfactory answer, you just say that because you try to be funny or you feel like it or if you are pissed off. You must get a proper bitch-slapping to stop making walls of text, but if you are weird then that doesn't apply to you. Walls of text are defeated by deleting them or splitting them into paragraphs. Or some other things that would work but will take hours to think of. People are considered a nuisance if they create walls of text. This might be the end. If you hope this is the end, I am not sure. But if I was not sure then I wouldn't be talking. I should know. Or should I? The best way to make a better and good wall of text is to copy and paste what you previously typed or write. Hey, that reminds me. Walls of text aren't always on the internet! They could be anywhere that is able to produce symbols. D'oh. A wall of text is something that is frowned upon in most, actually virtually all Internet societies, including forums, chat boards, and Uncyclopedia. You should not make walls of text because it can get you banned anywhere unless it is a place that encourages walls of text. I highly doubt any place does support something so irritating and annoying, but anything can exist, but not really because unless you are in heaven then that can happen. But no one actually knows that was just a hypothesis, a lame one that is. Actually not really lame. You can created a wall of text supporting site, but you would be hated if you do that, so do not. But you can if you like, but I discourage that. Now on to the actual information of walls of texts. The wall of text was invented when the Internet was invented, but actually it was slow at that time. So whenever it became fast. But there would need to be some free or not free community for people, and that community would be able to have walls of text. But that community probably wouldn't have actually invented the wall of text. So basically, no one except God and Al Gore knows when or where or how the wall of text existed/was invented. Noobs probably invented, but probably not. Who knows. Walls of texts are usually filled with a lot of useless information and junk. Information and junk can be the same, but only if the information is junk or the junk is information.
</p>
</div>
</div>
<div id="wrapper">
<img id="undir" src="undir.png"/>
</div>
</div>
</body>
</HTML>
CSS:
body, html {
margin: 0;
padding: 0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
.menu {
width:550px;
height:35px;
font-family:Trajan Pro;
font-size:18px;
text-align:center;
font-weight:bold;
text-shadow:3px 2px 3px #333333;
margin-left:1010px;
position:absolute;
top:150px;
}
.menu ul {
height: auto;
padding: 8px 0px;
margin: 0px;
list-style-type: none;
}
.menu li {
display: inline;
padding: 20px;
}
.menu a {
text-decoration: none;
color:white;
}
.menu a:hover {
text-shadow: 8px 5px 8px #333333;
font-size:20px;
}
#content {
min-height:100%;
position: relative;
width: 800 px;
height: 800px;
margin-right:200px;
margin-left:200px;
padding:10px;
padding-bottom:60px; /* Height of the footer */
}
#block1 { /*IGNORE THIS. I AM SAVING IT FOR LATER*/
background: red;
filter:alpha(opacity=20); /* IE */
-moz-opacity:0.2; /* Mozilla */
opacity: 0.2; /* CSS3 */
position: absolute;
top: 0; left: 0;
height: 100%; width:100%;
border-radius: 20px;
margin:10px;
}
#meginmal {
padding: 20px 30px 20px 30px;
text-align: center;
font-size:20px;
border-right: solid;
border-left: solid;
font-family: Trajan Pro;
}
#bordi {
height:100%;
width: 100%;
margin: 0%;
padding: 10px;
}
#wrapper {
position:absolute;
bottom:0;
width:100%;
height:60px; /* Height of the footer */
background:#6cf;
}
From your code, you have footer as id wrapper
Change the position from absolute to fixed
#wrapper {
position: fixed;
}
I'm trying to make a simple browser game without relying on anything fancy like flash or html5. I was doing pretty well in getting everything set up, but when I got to the ground I ran into trouble as I'm not very good at setting up html pages. I want to have a tiled ground that I can put objects on, then click on the objects to take the user to another page. I'm not sure how to go about something like this and am looking for some direction.
I have a fairly good grasp on PHP, understand basic html, very limited css and am starting to learn javascript and am planning on picking up jQuery.
I don't really understand what you want, but this might help:
Live Demo
To understand how the positioning works, see:
http://css-tricks.com/absolute-positioning-inside-relative-positioning/
http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/
HTML:
<div id="gameContainer">
</div>
CSS:
#gameContainer {
width: 320px;
height: 320px;
border: 1px solid #000;
background: url(http://i.stack.imgur.com/sFV9k.png);
position: relative
}
.wall {
background: url(http://i.stack.imgur.com/IFjyp.png);
width: 32px;
height: 32px;
position: absolute
}