HTML:
<div class="cont">
<center>
<div class="xmdiv">
<img class="xmenu" src="media/file1.png">
<img class="xmenu" src="media/file2.png">
</div>
</center>
<p>-snip-</p>
</div>
CSS
.cont {
position: relative;
margin-top: 3%;
background-color: transparent;
width: 65%;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 1px;
-moz-box-shadow: 0px 0px 11px #000000;
-webkit-box-shadow: 0px 0px 11px #000000;
box-shadow: 0px 0px 11px #000000;
font-family: 'Open Sans', sans-serif;
color: #070707;
font-size:15px;
font-weight:300;
text-align:justified;
line-height:1.5;
}
p {
margin-left: 8px;
margin-right: 8px;
}
What it looks like:
I want it to be centered, how do I do that? Tried looking it up online, and it didn't really work.
Is this what you want ? Link: http://jsfiddle.net/jtFUs/
CSS:
.cont
{
position: relative;
margin: 0 auto;
}
If you need to center a div vertically and horizontally on your page, use:
div {
width: 100px;
height: 100px;
background-color: #000000;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
http://jsfiddle.net/65adr/48/
In case you need to center it just horizontally, use:
center
{
width: 200px;
display: block;
margin-left: auto;
margin-right: auto;
}
Just define a width for the element, in this case i added 200px for example.
http://jsfiddle.net/65adr/50/
To center a div (and many other types of elements), use this CSS code:
.cont {
margin: 0 auto;
width: XXXpx;
}
JSFiddle.
Make sure to specify the width, or else the div won't be centered.
Edit
To center an element without specifying with, you could do something like this (not sure if this will work in all browsers, however):
body { text-align:center; }
.cont { display:inline-block; }
Side-note
Don't use the center tag, it is deprecated. You can read more about it here.
Related
I can't seem to make an element move in CSS. It's a form with a background and it's centered. I can't see what I'm doing wrong.
#skyformbox {
width: 50%;
margin: 0 auto;
margin-top: 0px;
clear: both;
border: 3px solid #000000;
padding-top: 20px;
background: #ccc url(http://www.ultraframehomeimprovements.co.uk/wp-
content/uploads/2018/07/Sky-box.png);
overflow: auto;
padding: 5;
left: 2000px;
}
<div align="left">
<div id="skyformbox">
[gravityform id="12" title="false" description="false"]
</div>
</div>
Why are you positioning 2000px left? As far as I know the "left" property will only work if the positioning is set to absolute...
Anyway try this:
#skyformbox {
width: 50%;
margin-left: 0px;
margin-top: 0px;
clear: both;
border: 3px solid #000000;
padding-top: 20px;
background: #ccc url(http://www.ultraframehomeimprovements.co.uk/wp-content/uploads/2018/07/Sky-box.png);
overflow: auto;
padding: 5;
left: 2000px;
}
Setting the margin-left to 0px did the trick for me (assuming that what you're trying to do here is to get the form to align to the left side of the page).
I have a header element in a header div but for some reason i can't seem to add any bottom margin or padding to it. Margin/padding top, left, and right work find however. is there a reason for this? here is my code.
html
<div id="Container">
<div id="Header">
<h1>My Webpage</h1>
</div>
</div>
css
#Container {
position: relative;
width: 96%;
height: 98%;
left:2%;
background-color: black;
border-radius: 10px;
box-shadow: 0px 0px 15px 5px;
}
/----------------------------------------/
#Header {
position: absolute;
height: 15%;
width: 100%;
/*background-color: red;*/
border-bottom: 2px solid #e8e2e2;
}
#Header h1 {
font-size: 2.5em;
text-align: center;
color:#e8e2e2;
/*background-color: red;*/
}
I would avoid using position styling like that; it tends to interfere with the way block elements interact with each other. Based on the styles and markup provided, I don't see a reason why padding/margin would not be working; however your example doesn't actually show any padding/margin applied, so it's hard to say what might be going wrong.
I would alter your styling thusly:
#Container {
width: 96%;
margin-left: auto;
margin-right: auto;
background-color: black;
border-radius: 10px;
box-shadow: 0px 0px 15px 5px;
}
#Header {
height: 15%; /* This should really be a static number, not a percentage*/
width: 100%;
border-bottom: 2px solid #e8e2e2;
margin-bottom: 20px; /* This will push elements below your header div down by 20 px*/
}
Try to add pading to header tag's self. Because it is relative to other containers.
#Container {
position:relative;
width: 96%;
height: 98%;
left:2%;
background-color: black;
border-radius: 10px;
box-shadow: 0px 0px 15px 5px;
}
#Header {
position:relative;
height: 15%;
width: 100%;
/*background-color: red;*/
border-bottom: 2px solid #e8e2e2;
}
#Header h1 {
position:relative;
padding-top:20px;
font-size: 2.5em;
text-align: center;
color:#e8e2e2;
/*background-color: red;*/
}
<div id="Container">
<div id="Header">
<h1>My Webpage</h1>
</div>
</div>
Firstly, please add #for Container as in #Container in css.
Below is the code where I have added margin bottom for h1. Please let me know if you still have any troubles.
<html>
<head>
<style type="text/css">
#Container {
position: relative;
width: 96%;
height: 98%;
left:2%;
background-color: black;
border-radius: 10px;
box-shadow: 0px 0px 15px 5px;
}
#Header {
position: absolute;
height: 15%;
width: 100%;
/*background-color: red;*/
border-bottom: 2px solid #e8e2e2;
}
#Header h1 {
font-size: 2.5em;
text-align: center;
color:#e8e2e2;
border:1px solid red;
margin-bottom:10px;
}
</style>
</head>
<body>
<div id="Container">
<div id="Header">
<h1>My Webpage</h1>
<p>some text here</p>
</div>
</div>
</body>
</html>
Hope this helps.
Thanks
Padding-bottom and margin-bottom does actually work, it's just that it's not visible because you're currently setting the height of #Header to 15% and then giving it that light grey bottom border. This is what gives the illusion that padding-bottom or margin-bottom doesn't work.
See working version here http://codepen.io/sajadtorkamani/pen/zxxzgo
HTML
<div id="Container">
<div id="Header">
<h1>My Webpage</h1>
</div>
</div>
CSS
Container {
position: relative;
width: 96%;
height: 98%;
left:2%;
background-color: black;
border-radius: 10px;
box-shadow: 0px 0px 15px 5px;
}
#Header {
position: absolute;
/* height: 15%; */
width: 100%;
/*background-color: red;*/
border-bottom: 2px solid #e8e2e2;
}
#Header h1 {
font-size: 2.5em;
text-align: center;
color:#e8e2e2;
padding-bottom: 20px;
/*background-color: red;*/
}
Just commenting out height: 15% for #Header solves the issue.
Ok this is my problem:
The left float and right float are somehow not put into my container and the footer only pays attention to the middle content part. What am I doing wrong?
I could show it with a picture but I cannot add one because I don't have 10 rep.
It must be a simple fix, I have read about clear:both etc but that all does not work unfortunately.
#container
{
position: relative;
width: 58.5%;
background: #FFFFFF;
margin: 0 auto;
border: 1px solid #336600;
text-align: left;
}
#header
{
height: 160px;
background-image:url(images/bannerboven.jpg);
}
#sideleft
{
position: absolute;
top: 160px;
left: 0;
float: left;
width: 22%;
background: #CCFFFF;
padding: 15px 10px 15px 20px;
}
#sideright
{
position: absolute;
top: 160px;
right: 0;
float:right;
width: 23%;
background: #CCFFFF;
font-size: 0.8em;
padding: 15px 10px 15px 20px;
}
#mainContent
{
margin: 0 26% 0 26%;
padding: 0 10px;
background: #0F0;
}
#footer
{
padding: 0 10px 0 20px;
background: #DDDDDD;
text-align: center;
font-weight: bold;
}
I'm not sure what you are trying to achieve without knowing your html structure, but the problem stems from the fact that you have absolute positioning on your left and right containers as well as a floted positioning.
The default positioning for a html element is static, so you either float everything or absolute position everything. Here's something to help you understand positioning better, it's very easy and you'll be on your way in 5 minutes: http://www.barelyfitz.com/screencast/html-training/css/positioning/
Also, you should post a jsfiddle link with the html included so we'll understand better what you are trying to achieve if you need further help. My guess is that Rohit Azad's solution is correct, you just have trouble understanding positioning.
Hi i check to your code i think you want to this
HTML
<div id="container">
<div id="header">Header</div>
<div id="mainContent">
<div id="sideleft">Left</div>
<div id="sideright">Right</div>
</div>
<div id="footer">Footer</div>
</div>
Css
#container
{
width: 58.5%;
background: #FFFFFF;
margin: 0 auto;
border: 1px solid #336600;
}
#header
{
height: 160px;
background:red;
background-image:url(images/bannerboven.jpg);
}
#sideleft
{
float:left; width: 22%;
background: #CCFFFF;
padding: 15px 10px 15px 20px;
}
#sideright
{
float:right;
width: 23%;
background: #CCFFFF;
font-size: 0.8em;
padding: 15px 10px 15px 20px;
}
#mainContent
{
padding: 20px 10px;
background: green;
overflow:hidden;
}
#footer
{
padding: 0 10px 0 20px;
background: #DDDDDD;
text-align: center;
font-weight: bold;
}
Live demo
I found this image while searching the web and I tried to implement this display on my own. This is what I have so far:
My HTML code is here:
<ul>
<li>
<span style="display:block;"><a href="">
<span><img src="../creation/images/samps/unnamed4.png" width="48" align="absmiddle"/></span>
<span class="price" >Freeep</span>
<span class="appname">Name of the apps that is so long</span>
<span class="developer">by scamexdotexe</span>
</a>
</span>
</li>
</ul>
This is my CSS style:
<style type="text/css">
li{
list-style: none;
width:200px;
border:1px solid #00CCFF;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
padding: 0px;
}
li:hover{
border:1px solid red;
}
li a{
margin: 0px;
display: block;
width: 100%;
height: 100%;
white-space:nowrap;
text-overflow:ellipsis;
overflow:hidden;
text-decoration:none;
padding:2px;
}
li a span img{
padding: 5px;
}
.price{
position:absolute;
margin-top:4px;
margin-bottom:4px;
color:#0099FF;
font-size:12px;
}
.appname{
}
.developer{
font-size:12px;
color:#666666;
margin:0;
position:inherit;
display:inline;
white-space:nowrap;
}
</style>
I spent hours on cloning the display on the first image but it seems that I have no luck. Can you point what I am doing wrong here? What I really want to do is align the app name and the price horizontally and also align the app name, rating, total downloads vertically.
For starters, I'd change the border radius to 5px, and add a drop shadow:
li {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-box-shadow: 0px 0px 5px #333;
-webkit-box-shadow: 0px 0px 5px #333;
box-shadow: 0px 0px 5px #333;
}
Do you want to use the same colors as well?
Here's a start for you: http://jsfiddle.net/k8ejp/4/
Notes:
the "avatar" div could of course be an image
absolute positioning can be used instead of floating if you want a more complex layout (or find it easier to work with position)
my example uses a few newer features of CSS (like text-overflow) but they should degrade without changing the layout.
HTML
<div class="box">
<div class="avatar">foo</div>
<div class="price">Free!</div>
<div class="name">A long app name A long app name A long app name A long app name</div>
<div class="info">Other info about the app goes here.</div>
</div>
CSS
.box{
font: 11px/1.5 sans-serif;
padding: 8px;
background-color: #ccddcc;
width: 400px;
border-radius: 4px;
border: 1px solid silver;
box-shadow: 2px 2px 2px #ddd;
}
.avatar {
width: 32px;
height: 32px;
background-color: #555;
float: left;
margin-right: 12px;
}
.price {
float: right;
color: green;
}
.name {
width: 200px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
I have created an example here: http://jsfiddle.net/D26Hj/1/.
It just needs an app logo and star sprite image.
I have drawn up a star sprite image and quickly made a fake logo in Paint.NET.
Info about the sprite:
Each star is 9px wide.
There are 5 stars in a rating, so therefore each rating is 45px wide.
Therefore, to change the rating change the background-position as per below.
Here are the background-positions to use for different star ratings:
-0px 0 Stars
-45px 1 Star
-90px 2 Stars
-135px 3 Stars
-180px 4 Stars
-225px 5 Stars
I have added classes to make it easier, use rating-0 to rating-5 for 0 stars to 5 stars.
HTML:
<div class="app">
<div class="image"></div>
<div class="title">
App title
</div>
<div class="price">$0.00</div>
<div class="rating rating-3">3 stars</div>
<div class="info">1024 downloads</div>
</div>
CSS:
body {
padding: 20px;
}
.app {
position: relative;
width: 225px;
height: 50px;
padding: 5px;
background: #8f8;
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
border: 1px solid #484;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
box-shadow: 0 0 2px #484;
-moz-box-shadow: 0 0 3px #888;
-webkit-box-shadow: 0 0 3px #888;
}
.app a {
text-decoration: none
}
.app .image, .app .title, .app .price, .app .rating, .app .info {
position: absolute;
}
.app .image {
left: 5px;
top: 5px;
width: 48px;
height: 48px;
background-image: url('http://i.imgur.com/JAgto.png');
}
.app .title {
left: 60px;
top: 7px;
}
.app .price {
right: 5px;
top: 7px;
color: #262;
}
.app .rating {
left: 65px;
top: 25px;
width: 45px;
height: 10px;
text-indent: -999px;
background-image: url('http://i.imgur.com/giWyQ.png');
background-position: -135px 0;
}
.app .info {
left: 60px;
top: 40px;
font-size: 11px;
color: #666;
}
.rating-0 {
background-position: 0 0;
}
.rating-1 {
background-position: -45px 0;
}
.rating-2 {
background-position: -90px 0;
}
.rating-3 {
background-position: -135px 0;
}
.rating-4 {
background-position: -180px 0;
}
.rating-5 {
background-position: -225px 0;
}
I'm not so sure you should use span, personally I would use div instead since it's default display style is already block, which I see is what you try to achieve on the description block.
And about the Price and AppName, I would suggest that you wrap them inside a Div container on the same level with rating and downloads count and make that container display style inline-block then adjust the width for both Price and AppName.
It would be like this
<div class="main-container">
<div class="image"> Image Goes Here </div>
<div class="description">
<div class="description-top">
<div class"description-top-title"> Title Goes Here</div>
<div class"description-top-price"> Price Goes Here</div>
</div>
<div class="description-middle"> Rating Goes Here</div>
<div class="description-bottom"> Download Count Goes Here</div>
</div>
</div>
.main-container{
display: inline-block;
}
.image{
width: 30%;
}
.description{
display: block;
width: 70%;
}
.description-top{
display: inline-block;
}
.description-top-title{
width: 60%;
}
.description-top-price{
width: 40%;
}
I have a google map in an iframe and wrapped in a div. Above that div, i have another, which serves to create a recessed shadow effect.
The problem is that this overlayed div will take priority of any mouse events, so it renders the interactive google map below useless. There must be a way I can make the overlayed div ignore mouse events, letting the div below get them. (please, please!)
Or, is there another way to do it?
here's the code being output:
<div id="pageWrapper" style="display: block; ">
<div class="page_content">
<div id="pageShadow"></div>
<div id="pageMap"><p><iframe width="1096" height="462" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Baked+Beans+B.V.+i.o.,+Amsterdam,+Nederland&sll=52.365721,4.891641&sspn=0.008648,0.022724&ie=UTF8&hq=baked+beans+bv+io&hnear=Amsterdam,+North+Holland,+The+Netherlands&ll=52.363837,4.891109&spn=0.01664,0.045447&z=14&iwloc=near&cid=2617758725349562441&output=embed"></iframe></p>
</div>
</div>
<div id="page_description">
<p>Text about the company</p>
</div>
<div id="page_credits">
<div class="recTitle">Job 1</div>
<div class="recJob"><p>Description</p>
</div>
<div class="recTitle">Job 2</div>
<div class="recJob"><p>Description</p>
</div>
<div class="recTitle"></div>
<div class="recJob"></div>
</div>
</div>
Here's the relevant CSS:
#pageWrapper {
position: relative;
}
.page_content {
max-height: 462px;
position: relative;
}
#pageShadow {
position: absolute;
top:0;
left: 0;
-moz-opacity: .5;
opacity:.5;
filter: alpha(opacity=50);
background-color: aqua;
z-index: 300;
min-height:462px;
min-width: 1096px;
}
#pageMap {
position: absolute;
top:0;
left: 0;
z-index: 299;
min-height:462px;
min-width: 1096px;
}
.recTitle {
color: #333;
font-size: 21px;
font-family: 'ProximaNovaLight', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding-left: 3px;
padding-bottom: 16px;
}
.recTitle:first-child {
padding-top: 10px;
}
.recJob {
padding-left: 3px;
padding-bottom: 30px;
}
#page_description {
position: absolute;
top:462px;
font-family: 'ProximaNovaLight', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 17px;
float:left;
width:792px;
padding: 15px;
padding-top:20px;
line-height: 22px;
font-weight: normal;
min-height: 345px;
background-color: white;
}
#page_credits {
position: absolute;
top:462px;
left:822px;
padding: 15px 10px 15px 10px;
float:right;
width:254px;
background-color: #f5f5f5;
min-height: 350px;
}
And here's the effect I'm trying to attain: (the shadow effect on the top)
div overlay http://baked-beans.tv/bb/wp-content/uploads/site-dev/google-map-inner-shadow-div-overlay.jpg
It is possible in Firefox 3.6+ thanks to its support for the "pointer-events" property, as explained in this post at Mozilla Hacks:
http://hacks.mozilla.org/2009/12/pointer-events-for-html-in-firefox-3-6/
There may be support in Webkit browsers, as mentioned in this post at CSS-Tricks:
http://css-tricks.com/pointer-events-current-nav/
But not in IE or Opera.
perhaps put the #pageShadow inside the pageMap element?
Make the #pageShadow div only as big as the shadow.
If I understand correctly from the mock up image, the effect you are trying to achieve is that the shadow should only cover the top part of the map.
In your code you are stretching the shadow div all over the map:
#pageShadow { .. min-height: 462px; min-width: 1096px; }
Why not decrease the values so that they cover only the top part:
#pageShadow { .. height: 20px; min-width: 1096px; }
Then you will have pointer access to the iframe.
I did something similar for my whole page:
.shadowframe_top{
margin: 0;
padding: 0;
box-shadow: 0px 5px 18px #333;
-webkit-box-shadow: 0px 5px 18px #333;
background-color:#F0F0F0;
width: 100%;
position: fixed;
top: -10px;
height: 10px;
}
.shadowframe_left{
margin: 0;
padding: 0;
box-shadow: 0px 5px 18px #333;
-webkit-box-shadow: 0px 5px 18px #333;
background-color:#F0F0F0;
height: 100%;
position: fixed;
left: -10px;
width: 10px;
}
.shadowframe_bottom{
margin: 0;
padding: 0;
box-shadow: 0px 5px 18px #333;
-webkit-box-shadow: 0px 5px 18px #333;
background-color:#F0F0F0;
width: 100%;
position: fixed;
bottom: -10px;
height: 10px;
}
.shadowframe_right{
margin: 0;
padding: 0;
box-shadow: 0px 5px 18px #333;
-webkit-box-shadow: 0px 5px 18px #333;
background-color:#F0F0F0;
height: 100%;
position: fixed;
right: -10px;
width: 10px;
}
and in the html simply insert four divs:
<div class="shadowframe_top"> </div>
<div class="shadowframe_left"> </div>
<div class="shadowframe_bottom"> </div>
<div class="shadowframe_right"> </div>
The trick is that, in my case, the div is outside the page and the shadow catches no clicks.