I have in general 3 areas in a WEB page (title and subtitle, 2 text columns and test in left and image at right). I would like to get following result:
However I do not know how to make it, I think it has to do with z-index of wine image, but how to do it?
I have this:
my current code is:
<header>
<div class="inner-header">
<h1><a title="title">titlw</a></h1>
<h2>subtitle</h2>
</div>
</header>
<section id="tagline">
<div id="tagline-content">column 1 and its text.</div>
<div id="tagline-content-middle">column 2 and its text.</div>
</section>
<section id="product">
<article class="product">
<img src="http://hmimexico.com/noir.png" alt="Girl" />
<h3>title</h3>
<p>Lorem Ipsum .</p>
</article>
</section>
css:
header {
margin-top: -40px;
height: 165px;
}
header .inner-header {
height:165px;
text-align:center;
}
header h1{
padding-top: 45px;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
margin-bottom:0;
}
header h2 {
color:#111111;
font-size: 19px;
line-height: 22px;
font-weight: bold;
letter-spacing: 1px;
margin-top:-2px;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.15);
text-transform:uppercase
}
#tagline {
padding: 10px 0 10px 0;
background:#111 ;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
}
#close-open-top {
margin: -9px auto;
text-align: center;
width: 50px;
}
#close-open-top a {
width:100px
}
#close-open-top:hover {
margin-top:-11px;
padding-bottom:2px
}
#tagline-content {
color: #FFFFFF;
text-align:left;
font-size: 10px;
font-weight: normal;
letter-spacing: 1px;
line-height: 100px;
text-transform: uppercase;
}
#tagline-content-middle {
color: #FFFFFF;
text-align:center;
font-size: 10px;
font-weight: normal;
letter-spacing: 1px;
line-height: 100px;
text-transform: uppercase;
}
#product {
text-align:center;
margin:16px auto;
padding-top:10px;
width:960px;
}
#product img {
float: right;
margin-left: 15px;
}
.product {
width:100%;
display:block;
margin:0;
text-align:left;
}
.product p {
color: #4F4F4F;
font-size: 16px;
line-height: 21px;
margin-bottom:38px
}
please take a look at the fiddle:
http://jsfiddle.net/2aEGp/1/
How can I get result as shown in image 1?
I believe this is what you are looking for (jsFiddle). I used a combination of the following:
width:33.3% and float:left on your columns. I set the first 2 to 33.3% even though there is not a third column but the product image takes the place of the third column.
overflow:hidden on the column containers, since the columns are now floating we need to set overflow on it wrapping #tagline div.
Negative margin-top on the product image, so that it goes above the column wrapper. There was no need to add z-index.
You can also view the jsFiddle fullscreen to see how it would look like in a browser window.
Here's a fiddle for you image on top
and here's the css and html code
<header>
<div class="inner-header">
<h1><a title="title">titlw</a></h1>
<h2>subtitle</h2>
<div class='imgCont'>
<img src="http://i.stack.imgur.com/Ava65.png" alt="Girl" />
</div>
</div>
</header>
<section id="tagline">
<div id="tagline-content">column 1 and its text.</div>
<div id="tagline-content-middle">column 2 and its text.</div>
</section>
<section id="product">
<!-- Main content area -->
<article class="product">
<h3>title</h3>
<p>Lorem Ipsum .</p>
</article>
</section>
css
header {
margin-top: -40px;
height: 165px;
}
header .inner-header {
height:165px;
text-align:center;
}
header h1{
padding-top: 45px;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
margin-bottom:0;
}
header h2 {
color:#111111;
font-size: 19px;
line-height: 22px;
font-weight: bold;
letter-spacing: 1px;
margin-top:-2px;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.15);
text-transform:uppercase
}
#tagline {
padding: 10px 0 10px 0;
background:#111 ;
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
}
.imgCont{
height:100%;
width:30%;
float:right;
}
#close-open-top {
margin: -9px auto;
text-align: center;
width: 50px;
}
#close-open-top a {
width:100px
}
#close-open-top:hover {
margin-top:-11px;
padding-bottom:2px
}
#tagline-content {
color: #FFFFFF;
text-align:left;
font-size: 10px;
font-weight: normal;
letter-spacing: 1px;
line-height: 100px;
text-transform: uppercase;
width:100%;
}
#tagline-content-middle {
color: #FFFFFF;
text-align:center;
font-size: 10px;
font-weight: normal;
letter-spacing: 1px;
line-height: 100px;
text-transform: uppercase;
width:100%;
}
#product {
text-align:center;
margin:16px auto;
padding-top:10px;
width:auto;
}
#product img {
float: right;
}
.product {
width:100%;
display:block;
margin:0;
text-align:left;
}
.product p {
color: #4F4F4F;
font-size: 16px;
line-height: 21px;
margin-bottom:38px
}
.product img{
position:relative;
}
I adjusted some designs with % so that it can get a bit responsive. You can try it in browser since fiddle uses and iframe so it some how behaves a little different than atual page in responsiveness.
I believe you should use css positioning to achieve this. Take a look at the following example
http://jsfiddle.net/2aEGp/5/
The css which makes this happen is the following
.product img {
position: absolute;
right: 50px;
top: 100px;
}
I have also rearranged the product section like the this
<section id="product">
<!-- Main content area -->
<article class="product">
<h3>title</h3>
<p>Lorem Ipsum .</p>
<img src="http://hmimexico.com/noir.png" alt="Girl" />
</article>
</section>
I think we can solve the above problem by applying float:left to #tagline-content and to #tagline-content-middle divs and using either clear:both(after the two divs in an empty div) or overflow:hidden(to parent div) to clear the floats.
We can also put the image at the apporpriate position using negative top margin or setting position as absolute and giving right and top values(keeping article position:relative;)
Related
How do I fill that circled space? I want to know how to fill the rest of the blue area with white background-color.
I tried increasing the padding, but that moved the price lower and lower and to the left a little each time I increased the padding.
My HTML looks like this..
section {
background-color: white;
}
#repair-tagline h1 {
background-color: white;
font-family: 'Open Sans Condensed', sans-serif;
letter-spacing: 0.2rem;
font-size: 3rem;
text-align: center;
padding: 40px 0 40px 0;
}
.repair-option {
background-color: rgb(0, 0, 77);
width: 80%;
padding: 50px 50px 50px 50px;
margin: 0px auto 50px auto;
}
.repair-type,
.repair-price {
display: inline-block;
color: white;
}
.repair-type {
font-size: 2rem;
}
.repair-price {
float: right;
background-color: white;
border: 1px solid black;
color: black;
font-size: 2rem;
}
<section>
<div class="repair">
<div id="repair-tagline">
<h1>Choose Your Vacuum Cleaner Repair Option:</h1>
</div>
<div class="repair-option">
<div class="repair-type">
<h1>Belt Repair</h1>
</div>
<div class="repair-price">
<h1>$10.00</h1>
</div>
</div>
<div class="repair-option">
<div class="repair-type">
<h1>Brush-Roll Repair</h1>
</div>
<div class="repair-price">
<h1>$20.00</h1>
</div>
</div>
</div>
</section>
Remove the padding from the class of repair-option and add individual paddings to the 2 child divs (repair-type and repair-price). That way, each of those had individual paddings which means the background-color corresponds to the div.
The padding for .repair-price may look weird, but I just did that because it wasn't lining up. You can change all the paddings to how you wish.
section {
background-color: white;
}
#repair-tagline h1 {
background-color: white;
font-family: 'Open Sans Condensed', sans-serif;
letter-spacing: 0.2rem;
font-size: 3rem;
text-align: center;
padding: 40px 0 40px 0;
}
.repair-option {
background-color: rgb(0, 0, 77);
width: 80%;
padding: 0px;
margin: 0px auto 50px auto;
}
.repair-type,
.repair-price {
display: inline-block;
color: white;
}
.repair-type {
font-size: 2rem;
padding: 10px;
}
.repair-price {
float: right;
background-color: white;
border: 1px solid black;
color: black;
font-size: 2rem;
padding: 10px 0px 8px 0px;
}
<section>
<div class="repair">
<div id="repair-tagline">
<h1>Choose Your Vacuum Cleaner Repair Option:</h1>
</div>
<div class="repair-option">
<div class="repair-type">
<h1>Belt Repair</h1>
</div>
<div class="repair-price">
<h1>$10.00</h1>
</div>
</div>
<div class="repair-option">
<div class="repair-type">
<h1>Brush-Roll Repair</h1>
</div>
<div class="repair-price">
<h1>$20.00</h1>
</div>
</div>
</div>
</section>
How can I place my button in the center without any kind of "margin cheat" (for example setting margin-left: 525px;)?
HTML
<div id="banner">
<div id="bannerContainer">
<h1>H1 tag</h1>
Products
</div>
</div>
CSS
.bannerButton {
border: 2px solid #fff;
color: #fff;
font-weight: 300;
font-family: 'Raleway';
font-size: 20px;
display: inline-block;
background-color: rgb(63, 127, 191);
padding: 18px 60px 18px 50px;
margin-bottom: 50px;
margin-top: 50px;
position: relative;
margin-left: 525px;
}
.bannerButton:hover {
text-decoration: none;
background: #eaf;
color: #fff;
}
I've tried making it sit in the center but it didn't work out so well without me setting margin-left; 525px;, which in my case, centers the button under the text, please help me remove this "margin cheat" and do it in the right way.
The a act like text it means when you give text-align:center; to its parent, it will be placed in center of its parent.
You don't need to give margin to the a element. You can use text-align:center;.
#bannerContainer
{
text-align:center;
}
.bannerButton {
border: 2px solid #fff;
color: #fff;
font-weight: 300;
font-family: 'Raleway';
font-size: 20px;
display: inline-block;
background-color: rgb(63, 127, 191);
padding: 18px 60px 18px 50px;
margin-bottom: 50px;
margin-top: 50px;
position: relative;
}
.bannerButton:hover {
text-decoration: none;
background: #eaf;
color: #fff;
}
<div id="banner">
<div id="bannerContainer">
<h1>H1 tag</h1>
Products
</div>
</div>
If you set the position of the button to absolute, give it a set width, and add this it should center:
left: 50%; right: 50%;
Have you try this:
<center>Products</center>
I am not sure whether it is helpful to you..
I was just wondering how I can better optimize my website (its just a project, not real) for Snap mode in Windows. Whenever I go into that mode, it screws up the entire webpage (see attached photo).
Thanks Jacob
http://i.stack.imgur.com/V4yF2.jpg
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<link type="text/css" rel="stylesheet" href ="C:\Users\toshiba\Documents\NetBeansProjects\HTML5Application\public_html\css\index.css">
<link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/shift.css" rel="stylesheet">
<link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css" rel ="stylesheet">
<meta charset="UTF-8">
<title> JP's Webservices</title>
</head>
<body>
<div id ="body">
<div class = "nav">
<ul>
<li>
About Me
</li>
<li>
Contact Me
</li>
<li>
Pricing
</li>
</ul>
</div>
<div class ="jumbotron">
<div class ='container'>
<div id ='h1'>
<h1> Need a website? </h1>
<p> Look no further </p>
</div>
</div>
</div>
<div id ="white">
<h1> Qualities </h1>
<h3> What makes me unique? </h3>
</div>
<div id ="gray">
</div>
<div class ="des" >
<div class ="row">
<div class= "col-md-4">
<h2> Knowledge. </h2>
<p> Straight 'outta Compton 1231231231231231231231231231231231231231231231231231231231 </p>
<hr>
</div>
<div class="col-md-4">
<h2> Commitment. </h2>
<p> To excellence and to serve as a value resource 123123123123123123123123123123123123 </p>
<hr>
</div>
<div class="col-md-4">
<h2> Perspective. </h2>
<p> New outlook on your web designs 12312312312311111111111111111111111111111111111111111 </p>
<br>
</div>
</div>
</div>
</body>
<footer>
<div id ='footer'>
</div>
<div id ='footer1'>
<p> Copyright #2014-2015 Jacob Platin </p>
<div id ='foot1'>
<a href="https://twitter.com/TheJakeoShark" target=newtab><img src="https://g.twimg.com/Twitter_logo_blue.png" width="72" height="46" border="0" /></a>
</div>
<div id ='facebook'>
<a href ='https://facebook.com/jacob.platin' target=newtab><img src = 'http://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/F_icon.svg/267px-F_icon.svg.png' width ="65" height =" 53" /></a>
</div>
</div>
</footer>
</html>
CSS
.des {
position: absolute;
font-family: 'Georgia', sans-serif;
text-shadow: 2px 3px 3px rgba(0,0,0,0.5);
text-align: center;
}
.nav li {
list-style-type: none;
text-align: center;
float: left;
width: 33.3%;
position: relative;
z-index: 10;
color: black;
padding-top: 17px;
font-weight: 700;
font-size: 18px;
}
.nav {
background-color: #660000;
height: 85px;
z-index: 1;
box-shadow: 1px 1px 5px black;
}
.nav a {
text-decoration: none;
color: black;
font-weight: 700;
color: white;
}
.jumbotron {
position:relative;
background-image: url(http://www.welivesecurity.com/wp-content/uploads/2013/01/012838004-printed-internet-html-code-tec.jpg);
width: 100%;
height: 530px;
}
#h1 > h1 {
color:#660000;
text-align:left ;
padding-top: 34px;
font-family: 'Georgia', sans-serif;
text-shadow: 2px 3px 3px black;
}
#h1 > p {
color:white;
text-align:left ;
padding-left: 5px;
font-family: 'Georgia', sans-serif;
text-shadow: 2px 3px 3px black;
font-weight: 300;
}
#master_wrapper{overflow:hidden!important;}
#footer {
width: 1902px;
height: 170px;
background-color: black;
box-shadow: 1px 1px 12px 4px black;
position: absolute;
top: 1300px;
}
#footer1 {
height: 85px;
width: 1902px;
background-color: #660000;
position: absolute;
margin-top: 0px;
box-shadow: -4px -2px 9px black;
top: 1300px;
}
#footer1 > p {
text-align: center;
font-family: 'Georgia', sans-serif;
color: white;
font-size: 18px;
padding-top: 24px;
}
#foot1 {
padding-top: 42px;
text-align: center;
padding-left: 205px;
}
#facebook {
margin-left: 820px;
position: absolute;
bottom: 3px;
top: 95px;
}
.des > h2 {
padding-top: 80px;
color: #660000
}
#photo1 {
background-image: url(http://financeandcareer.com/wp-content/uploads/2013/03/webProgrammingInternship.jpg);
width: 240px;
height: 200px;
position:relative;
}
.des > img {
margin-top: 40px;
box-shadow: 01px 01px 01px 5px black;
}
#h1 {
box-shadow: -1px -1px -32px black;
}
#gray {
width: 100%;
height: 300px;
background-color: #f7f7f7;
position: absolute;
z-index: -11;
margin-top: 0px;
}
#white > h1 {
z-index: 1;
padding-bottom: 100px;
font-family: 'Georgia', sans-serif;
text-shadow: 2px 3px 3px rgba(0,0,0,0.5);
color:#660000;
text-align: center;
}
#white > h3 {
font-family: 'Georgia', sans-serif;
text-shadow: 2px 3px 3px rgba(0,0,0,0.5);
color:#660000;
position: absolute;
bottom: 230px;
text-align:center;
z-index: 0;
margin-left: 43.3%;
}
.row {
padding-left: 56px;
z-index:-1;
}
Are you referring to resizing the site via snapping (taking up 50%) of the screen width? If you want your site to work whatever the the screen width you need to use fluid containers and media queries, which make up the concept of responsive web design.
From the looks of things your site uses fixed widths which limit the ability for the content to re-size fluidly with the browser when you snap.
Responsive webdesign needs to be integrated form the get go, it can be annoying to update an existing site (but still possible). I'd recommend taking a look at this tutorial/overview: http://www.w3schools.com/html/html_responsive.asp
In short to fix your site you will need to get rid of the fixed widths you have set in pixels and uses percentages as they will adapt depending on the available width.
I am Trying to create this One page containing different divs with 100% width.
But, when I insert a 'h2' at top of div, itcreates gap between two div's.
assigning top margin removes this gap, but I want the 'h2' at top only.
here's JSFiddle
HTML:
html,
body {
height: 100% !important;
width: 100% !important;
margin: 0px;
padding: 0px;
}
.mainDiv {
height: 500% !important;
width: 100% !important;
}
.page {
height: 20% !important;
width: 100% !important;
text-align: center;
}
#headerDiv {
height: 15%;
position: fixed;
background-color: #7f4c76;
width: 100%;
box-shadow: 0px 5px 5px rgba(0, 0, 0, 0.4);
}
#div1 {
padding-top: 5%;
background-color: #334960;
}
#div2 {
background-color: #f17c72;
}
#div3 {
background-color: #32ac97;
}
#div4 {
background-color: black;
}
#div5 {
background-color: yellow;
}
h1 {
color: #E6E6E6;
margin-left: 50px;
font-family: "MS Sans Serif", Geneva, sans-serif;
font-size: 300%;
text-shadow: 0px 5px 5px rgba(0, 0, 0, 0.4);
}
h2 {
color: #E6E6E6;
font-weight: normal;
font-family: 'Signika', sans-serif;
font-size: 300%;
}
<div class="mainDiv">
<div id="headerDiv">
<h1>CSS3 Demo </h1>
</div>
<div id="div1" class="page">
<h2>Text Effects Demo</h2>
</div>
<div id="div2" class="page">
<h2>Transition Demo</h2>
</div>
<div id="div3" class="page">
<h2>Animation Demo</h2>
</div>
<div id="div4" class="page">
<h2>Multiple Columns</h2>
</div>
<div id="div5" class="page">
<h2>Multiple Columns</h2>
</div>
</div>
Please Help.
Edit screenshot added:
Add this to your h2
h2 {
margin:0;
}
You issue is that your div has a default margin, of which can be overwritten using this styling
If I understood you correctly, you want the <h1>from the headerDivto have margin-top:0px; if this is what you want then the fix is quite simple:
#headerDiv h1 {
margin-top:0px;
}
Or if you want it to be only the direct descendants from the headerDiv you could do the following:
#headerDiv > h1 {
margin-top:0px;
}
Here you can find the fiddle updated: http://jsfiddle.net/s0p8ogdb/3/
After seeing the screenshot recently added you can fix this simply by making the page class display:inline-block, here's an updated fiddle: http://jsfiddle.net/s0p8ogdb/4/
Try this :
h2 {
color: #E6E6E6;
font-weight: normal;
font-family: 'Signika', sans-serif;
font-size: 300%;
margin-top:0;
}
#div1 h2 {
padding-top: 1em
}
I have adjusted my bottom attribute to display how I want it in Firefox, but the spacing is all warped in Chrome and Safari. Is there a way to sett a different "top" attribute for each browser?
HTML
<a class="tooltip" href="#"> <!-- this tag activates my tool tip -->
<div class="handsevent" > <!-- this div contains everything that activates the tool tip when hovered over-->
<div class="handswrapper">
<div class="handshour" >
<h3>8:00am-noon</h3>
</div>
<div class="handsspeaker">
<h3>Speaker 3</h3>
</div>
</div>
<div class="handstitle">
<p>Description</p>
</div>
</div>
<span class="classic"> <!-- this span contains everything that pops up in the tool tip -->
<h3>Title Bar</h3>
<br />lots of descriptive text
</span>
</a>
CSS
/* HOVER WINDOW */
.tooltip {
color: #000000; outline: none; font-style:bold;
cursor: help; text-decoration: none;
position: relative;
}
.tooltip span {
margin-left: -999em;
position: absolute;
}
.tooltip:hover span {
border-radius: 30px 30px; -moz-border-radius: 30px; -webkit-border-radius: 30px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
font-family: Arial, Tahoma, Helvetica, sans-serif;
position: auto; left: 1em; top: 2em; z-index: 99; <!-- the 'top' attribute on this line is where I have been adjusting the display position it affects the position differently in different browsers -->
margin-left: 0; width: 700px; margin-top:-10px;
}
.tooltip:hover img {
border: 0; margin: -30px 0 0 90px;
float: right; position:fixed;
z-index: 99;
}
.tooltip:hover em {
font-family: Arial, Tahoma, Helvetica, sans-serif; font-size:14px; font-weight: bold; color:005DA4;
display: block; padding: -0.2em 0 0.6em 0;
}
.classic { padding: 0.8em 1em; }
* html a:hover { background: transparent; }
.classic {background: #ffffff; border: 1px solid #ffffff; }
I have tried pixels, em, and percentage. None of these have been consistent. Are there browser specific settings I could use?
here is a demo link for reference.
Using a CSS Reset will help to eliminate differences between browsers.
I switch the top attribute in ".tooltip:hover span" to "auto" and that seems to be working.