I am making a website on my laptop and I have positioned images in a certain way, but when I look at it on my PC the images are still in the shape just not in the center of the page there to the right more.
Heres the HTML:
<div id="puzzle">
<a href="teeth.html">
<IMG STYLE="position:absolute; TOP:35px; LEFT:640px; WIDTH:250px; HEIGHT:250px" SRC="TeethGrinding.jpg"" title="Bruxism - Teeth Clenching & Grinding - Click here for more info!">
</a>
<a href="weight.html">
<IMG STYLE="position:absolute; TOP:35px; LEFT:820px; WIDTH:250px; HEIGHT:250px" SRC="weightloss.png"" title="Weight Loss (VGB)- Click here for more info!">
</a>
<a href="alcohol.html">
<IMG STYLE="position:absolute; TOP:35px; LEFT:1000px; WIDTH:250px; HEIGHT:250px" SRC="achol.png"" title="Alcohol Problems - Click here for more info!">
</a>
<a href="stress.html">
<IMG STYLE="position:absolute; TOP:215px; LEFT:640px; WIDTH:250px; HEIGHT:250px" SRC="stress.png"" title="Stress & Anxiety - Click here for more info!">
</a>
<a href="child.html">
<IMG STYLE="position:absolute; TOP:215px; LEFT:820px; WIDTH:250px; HEIGHT:250px" SRC="child.png"" title="Hypnotherapy for Children - Click here for more info!">
</a>
<a href="sleep.html">
<IMG STYLE="position:absolute; TOP:215px; LEFT:1000px; WIDTH:250px; HEIGHT:250px" SRC="sleep.png"" title="Insonmia & Sleep Disorders - Click here for more info!">
</a>
<a href="fear.html">
<IMG STYLE="position:absolute; TOP:395px; LEFT:640px; WIDTH:250px; HEIGHT:250px" SRC="fear.png" title="Fears & Phobias - Click here for more info!">
</a>
<a href="sport.html">
<IMG STYLE="position:absolute; TOP:395px; LEFT:820px; WIDTH:250px; HEIGHT:250px" SRC="sportpuzzel.png"" title="Sport Hypnotherapy - Click here for more info!">
</a>
<a href="smoking.html">
<IMG STYLE="position:absolute; TOP:395px; LEFT:1000px; WIDTH:250px; HEIGHT:250px" SRC="smoker.png"" title="Stop Smoking - Click here for more info!">
</a>
</div>
Here is the css:
#puzzle
{
background-color:white;
background-position: center;
background-size: cover;
float:center;
font-weight: 300;
color: black;
position:center;
text-align:center;
line-height: 25px;
width:100%;
overflow-x: hidden;
overflow-y: hidden;
height:685px;
word-spacing:3px;
position:relative;
}
Anyone know how to fix this?
There's quite a bit of invalid CSS for #puzzle. On top of that, you did not provide enough for me to actually test this. However I can give you an example of (my personal favorite) a common method to center a block element vertically, horizontally, or both.
For this method to work, we need to set a fixed width and (depending if vertically centered) height. The trick is to set the block element's left and top to 50% of the screen, and then use negative margin values to pull it back into place, by half of what we know the element's fixed size to be.
#centered {
background-color:#000;
height:75px;
left:0px;
position:absolute;
top:0px;
width:75px;
}
#centered > span {
display:block;
height:25px;
position:absolute;
width:25px;
}
#centered.horizontally { left:50%; margin-left:-37px; }
#centered.vertically { margin-top:-37px; top:50%; }
#one { background-color:#f00; left:0px; top:0px; }
#two { background-color:#0f0; left:25px; top:0px; }
#three { background-color:#00f; left:50px; top:0px; }
#four { background-color:#ff0; left:0px; top:25px; }
#five { background-color:#f0f; left:25px; top:25px; }
#six { background-color:#0ff; left:50px; top:25px; }
#seven { background-color:#333; left:0px; top:50px; }
#eight { background-color:#777; left:25px; top:50px; }
#nine { background-color:#aaa; left:50px; top:50px; }
<div class="horizontally vertically" id="centered">
<span id="one"></span><span id="two"></span><span id="three"></span>
<span id="four"></span><span id="five"></span><span id="six"></span>
<span id="seven"></span><span id="eight"></span><span id="nine"></span>
<div>
I hope you can use this example explains this simple method well enough, to be able to easily apply it to your own project(s).
Related
I have this problem, I can't seem to figure out how do I make this red DIV not past through the div on the right side, I want to make it stay between the right and the left div menu.
Website Screenshot
HTML Code:
<body>
<div class="navigationBar_default">
<div class="facetubeLogo_default"></div>
<div class="facetubeText_container_default"><center><strong class="facetubeText_default"></strong></center></div>
</div>
<div class="content_default">
<div class="leftMenu_onProfile">
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/myProfileButton_onLeftMenu_onProfile.png" /><br>MY PROFILE</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/optionsButton_onLeftMenu_onProfile.png" /><br>GENERAL</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/generalButton_onLeftMenu_onProfile.png" /><br>OPTIONS</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/supportUsButton_onLeftMenu_onProfile.png" /><br>SUPPORT US</button>
<button class="leftMenu_buttonOnProfile"><img class="leftMenu_buttonImage" src="images/logOutButton_onLeftMenu_onProfile.png" /><br>LOG OUT</button>
</div>
<!-- there must be some stuff here, otherwise leftMenu_onProfile will glitch out. -->
<div class="contentCenter_onProfile">
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAA
</div>
<!-- there must be some stuff here, otherwise leftMenu_onProfile will glitch out. -->
<div class="rightMenu_onProfile">user1<br>user2<br>user3<br>user4<br>user5</div>
</div>
CSS Code:
.navigationBar_default {
background-color:#202020;
width:100%;
height:32px;
margin-left:-8px;
margin-right:-8px;
border:0;
top:0;
position:fixed;
}
.facetubeLogo_default {
background-image:url("../images/facetube_icon_30x30_png.png");
width:30px;
height:30px;
margin-top:1px;
margin-left:1px;
float:left;
}
.facetubeText_container_default {
margin-top:6px;
}
.content_default {
width:100%;
height:100%;
margin-top:32px;
margin-left:-8px;
margin-right:-8px;
margin-bottom:-8px;
}
.leftMenu_onProfile {
background-color:#0d0d0d;
margin-top:0px;
margin-left:-8px;
width:240px;
float:left;
}
.leftMenu_buttonOnProfile {
background-color:#0d0d0d;
border:0;
border-bottom:1px solid #ffffff;
width:240px;
height:48px;
color:#ffffff;
}
.leftMenu_buttonImage {
float:left;
margin-top:-2px;
margin-right:-6px;
}
.contentCenter_onProfile {
background-color:red;
padding:2px; /* padding is originally removed */
margin:0px;
top:0px;
}
.rightMenu_onProfile {
background-color:#0d0d0d;
margin-top:-20px;
margin-right:-16px;
width:300px;
color:#ffffff;
float:right;
}
I have feeling it has to do something with content_default and the width:100% but I don't know. I tried everything and I couldn't figure it out.
:/
Try this:
.contentCenter_onProfile {
background-color:red;
padding:2px; /* padding is originally removed */
margin:0 300px;
top:0px;
width: 50%; /* SET THIS */
white-space: pre-wrap;
word-break: break-all;
}
By setting the width, you can ensure the div does not overlap the right hand side div.
Setting float: left or float: right causes the elements to overlap.
I am working for this company that has hired me to turn a new home page design of theirs into html and css. In the design they gave me there is a search box in the header that they would like to be same as the one on their current webpage (http://shop.manorfinewares.com/intro.html). I am unsure how to navigate their current page's source code in order to successfully transfer the search box to the new page I am designing for them. Here is the header code that I have so far...
CSS:
#header{
position:absolute;
width:100%;
top:0;
height:107px;
min-width:600px;
border-bottom: 1px dotted #86beca;
}
#headerContainer{
position:relative;
width:100%;
margin:0 auto;
top:0;
height:107px;
max-width:1280px;
min-width:600px;
border-bottom: 1px dotted #86beca;
}
.headerUtilityContainer{
float:left;
padding-top:4px;
margin-left:8%;
width:22%;
height:103px;
}
.headerUtilityContainer img{
float:left;
margin-top:2px;
width:40%;
height:9px;
}
.headerLogoContainer{
float:left;
margin:0px;
width:40%;
height:107px;
}
.headerLogoContainer img {
display:block;
margin-top:30px;
margin-left:auto;
margin-right:auto;
width: 55%;
max-width:250px;
height: 57%;
}
.searchContainer{
float:left;
text-align:right;
font-size:70%;
padding-top:4px;
margin-right:8%;
width:22%;
height:103px;
}
.headerBorderDiv{
float:left;
width:100%;
margin:0 auto;
padding:0px;
height:2px;
border-bottom: 1px dotted #86beca;
HTML:
<div id="header">
<div id="headerContainer">
<div class="headerUtilityContainer">
<img src="images/manorSocialButtons.png" />
</div>
<div class="headerLogoContainer">
<img src="images/homePageLogo.png"/>
</div>
<div class="searchContainer">
LOGIN / REGISTER CART (0)
</div>
</div>
</div>
ANY advice will be very helpful as I am not sure where to start. I have never worked with XLS search bars in the past
It's still unclear as to what exactly you want, a right floated search bar with clear icon on input? I have created this fiddle for you, it replicates the behaviour of site you mentioned.
http://jsfiddle.net/DP22Y/
HTML
<div id="container">
<div id="utility">Utility</div><!--
--><div id="logo">Logo</div><!--
--><div id="search">LOGIN / REGISTER | CART (0)
<span class="clearable">
<input class="data_field" type="text" name="search" placeholder="Search..."/>
<span class="icon_clear">x</span>
</span>
</div>
</div>
CSS
#container{
margin:0 auto;
height:100px;
width:80%;
}
#utility, #logo, #search{
box-sizing: border-box;
color:#000;
height:100%;
float:left;
}
#utility{
background:#f1f1f1;
width:33.3%;
padding:10px;
}
#logo{
background:#e0e0e0;
width:33.3%;
padding:10px;
}
#search{
background:#e9e9e9;
width:33.3%;
padding:10px;
text-align:right
}
#search > #data_field{
margin:10px 0 10px;
padding:5px;
width:100px;
float:right;
}
span.icon_clear{
position:absolute;
right:10px;
top:0px;
display:none;
cursor:pointer;
font: bold 1em sans-serif;
color:#38468F;
}
span.icon_clear:hover{
color:#f52;
}
.clearable{
position:relative;
}
.data_field{
padding-right:17px; /* add space for the 'x' icon*/
width:100px;
}
jQuery
$(document).on('propertychange keyup input paste', 'input.data_field', function(){
var io = $(this).val().length ? 1 : 0 ;
$(this).next('.icon_clear').stop().fadeTo(300,io);
}).on('click', '.icon_clear', function() {
$(this).delay(300).fadeTo(300,0).prev('input').val('');
});
As far as the functionality is concerned, that is a different question altogether. That depends on what language you are using, do you want to make the results appear on page reload or without that using ajax, whats the db scheme etc. But the basic search would be something like this
Wrap search field with a form
Set an action and method for the form
Action will be the page the search results will be shown on
I have created a image with some text as shown in figure.
<span class="productname ">Excusite Beauty</span>
<img src="xy.jpg" data-attr="productimg" class="productimg " />
My css is
.productimg
{
float:right;
margin-top:15px;
height:120px;
margin-right:2%;
border:2px double #0ff;
width:150px;
right:0px;
position:absolute;
}
.productname
{
font-size:1.2em;
display:block;
float:left;
}
How can i protect the overlapping of text and put the text in next line if it is long.
How to do it using css...plz help
after removing position and right=0
You are absolutely positioning the product image. This takes it out of the normal "flow" of the document, and will cause this overlap.
Remove position: absolute from .productimg (you can go ahead and remove right:0px; as well) , and the text should wrap around the image properly. To allow the text to float around the image, you can either move it before .productname or float .productname and give it a width.
codepen
HTML
<div class="product">
<img src="xy.jpg" data-attr="productimg" class="productimg " />
<span class="productname ">Excusite Beauty</span>
</div>
CSS
.productimg {
float:right;
/* margin-top:15px; */
height:120px;
border:2px double #0ff;
width:150px;
}
.productname {
font-size:1.2em;
display:block;
width:150px
}
.product {
width:300px;
}
What is the best way to set up a separate link for each colored circle in my image below?
The goal is to have each colored circle link to a different page and have them not interfere with one another. If I chop them into slices, each image will of course really be a square, thus interfering with the one under it (orange circle into blue circle for example).
I know I can use an imagemap (area). But I prefer a non-imagemap implementation due to a current border bug in chrome for imagemaps, and google's preference for non-imagemaps (SEO).
Ideas?
EDIT: This image is just a representation of what I actually when design is done, which are a bunch of circles with designs in them, so the image piece is a necessity.
How about something like this: http://jsfiddle.net/avTa8/
(No need for sprites/images, but you'll need support for border-radius [see http://css3pie.com/ ])
demo only uses border-radius, use -moz-border-radius for FF support, etc.
html
<div id="a" onclick="window.location='http://www.google.com';"></div>
<div id="b" onclick="window.location='http://www.stackoverflow.com';"></div>
<div id="c" onclick="window.location='http://www.stackoverflow.com';"></div>
<div id="d" onclick="window.location='http://www.stackoverflow.com';"></div>
<div id="e" onclick="window.location='http://www.stackoverflow.com';"></div>
<div id="f" onclick="window.location='http://www.stackoverflow.com';"></div>
css
#a:hover,
#b:hover,
#c:hover,
#d:hover,
#e:hover,
#f:hover {
cursor:pointer;
background-color:#333;
}
#a {
position:absolute;
border-radius:100px;
background-color:#72CEE0;
width:100px;
height:100px;
left:150px;
}
#b {
position:absolute;
border-radius:90px;
background-color:green;
width:90px;
height:90px;
top:130px;
left:50px;
}
#c {
position:absolute;
border-radius:100px;
background-color:orange;
width:100px;
height:100px;
top:60px;
left:85px;
}
#d {
position:absolute;
border-radius:80px;
background-color:red;
width:80px;
height:80px;
top:130px;
left:210px;
}
#e {
position:absolute;
border-radius:80px;
background-color:purple;
width:80px;
height:80px;
top:200px;
left:270px;
}
#f {
position:absolute;
border-radius:100px;
background-color:magenta;
width:100px;
height:100px;
top:220px;
left:150px;
}
I have a picture that needs to be split into 4, and each part must have a link.
Do people still use image hotspots?
I am assuming you are talking about client side image maps.
They are still being used and are part of HTML 4.01 and XHTML 1.1, and also in the current HTML 5 draft.
They are simple to use and are supported by all browsers and as such are a good way to have "hot spots" on a single image. I can't think of a single better alternative (ease of use, browser support, accessibility, being part of the HTML spec) that will give you this functionality.
Whether having such "hot spots" on a single image is advisable (discoverability by the user being the main issue), is a different question.
Using images as links is lame in my opinion; it can hurt accessibility, and depending on the image used, can result in Mystery Meat Navigation, which is lame.
Instead, I'd make that image a background image.
HTML
<div id="image-hotspot">
Small Planets
Big Planets
The Sun
</div>
CSS
#image-hotspot {
background:url(http://onlyfunnyjokes.com/bestoftheweb/wp-uploads/earth_planets_size_comparison.jpg);
height:650px;
width:385px;
}
#image-hotspot a {
display:block;
text-indent:-10000px; /* you could also change the opacity instead*/
/* as a matter of fact I suggest using the opacity technique */
/* the text-indent has caused me troubles in the iPad browser */
height:216px;
}
You might need to use more advanced CSS positioning to make sure those anchor elements <a> are where you need them to be.
Addendum
Here's another example which should seem more relevant:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" >
<head>
<title >Test</title>
<style type="text/css">
#image-hotspot {
background:url(http://upload.wikimedia.org/wikipedia/commons/c/c4/Planets2008.jpg);
height:720px;
width:1280px;
position:relative;
top:0px;
left:0px;
}
#image-hotspot a#the-sun {
display:block;
text-indent:-10000px;
height:720px;
width:200px;
position:absolute;
left:0px;
top:0px;
}
#image-hotspot a#mercury {
display:block;
text-indent:-10000px;
height:25px;
width:25px;
position:absolute;
left:225px;
top:275px;
}
#image-hotspot a#venus {
display:block;
text-indent:-10000px;
height:75px;
width:40px;
position:absolute;
left:265px;
top:250px;
}
#image-hotspot a#earth {
display:block;
text-indent:-10000px;
height:75px;
width:45px;
position:absolute;
left:325px;
top:250px;
}
#image-hotspot a#mars {
display:block;
text-indent:-10000px;
height:75px;
width:45px;
position:absolute;
left:383px;
top:250px;
}
#image-hotspot a#jupiter {
display:block;
text-indent:-10000px;
height:125px;
width:135px;
position:absolute;
left:450px;
top:225px;
}
#image-hotspot a#saturn {
display:block;
text-indent:-10000px;
height:125px;
width:195px;
position:absolute;
left:610px;
top:225px;
}
#image-hotspot a#uranus {
display:block;
text-indent:-10000px;
height:75px;
width:60px;
position:absolute;
left:805px;
top:250px;
}
#image-hotspot a#neptune {
display:block;
text-indent:-10000px;
height:75px;
width:60px;
position:absolute;
left:887px;
top:250px;
}
</style>
</head>
<body>
<div id="image-hotspot">
<a id="the-sun" href="#the-sun">the sun</a>
<a id="mercury" href="#mercury">mercury</a>
<a id="venus" href="#venus">venus</a>
<a id="earth" href="#earth">earth</a>
<a id="mars" href="#mars">mars</a>
<a id="jupiter" href="#jupiter">jupiter</a>
<a id="saturn" href="#saturn">saturn</a>
<a id="uranus" href="#uranus">uranus</a>
<a id="neptune" href="#neptune">neptune</a>
<!-- <a id="pluto" href="#pluto">pluto</a> -->
</div>
</body>
</html>
You can use image maps, the main reason people don't like them is because people often map a small part of an image and you don't know it's a link. If you can, just wrap the each image in it's respect <a href='link'>img</a>