I have 3 div blocks, the first one is bigger on the left hand side of the web-page and the other are smaller in located the right hand side. I want their relative location become fixed in all browsers with any zoom level. The two div blocks in the right column drop down below the first big div if I zoom in now.
Here is JFFIDDLE link of the code, please zoom in/out to see the issue.
<div id="topdiv">
<div class="bigdiv">
<p> big div </p>
</div>
<div id="staticcal">
<p> staticcal </p>
</div>
<div id="staticnews">
<p> staticnews </p>
</div>
</div
#topdiv{
display: inline-block;
background-color:#b0c4de;
}
.bigdiv{
margin: 10px 0;
position: relative;
width: 335px;
height: 250px;
float: left;
border: 2px solid #c7930d;
}
#staticcal {
width: 220px;
height: 100px;
line-height: 175px;
float: right;
display: inline-block;
border: 2px solid #c7930d;
border-radius: 4px;
margin: 5px;
margin-top: 10px;
margin-right: 0px;
position: relative;
}
#staticnews {
width: 220px;
height: 100px;
line-height: 175px;
float: right;
display: inline-block;
border: 2px solid #c7930d;
border-radius: 4px;
margin: 5px;
margin-right: 0px;
position: relative;
}
Add min-width: 800px; to the #topdiv id in your CSS file.
CSS:
#topdiv {
display: inline-block;
background-color:#b0c4de;
min-width: 800px;
}
I noticed that you are using border-radius in your development, so I updated your file to account for cross browser use. Here is an updated JSFiddle for your review. Additionally I lined up your staticcal and staticnews by adding float: left. Here is a minified version of your code: CLICK HERE
HTML:
<div id="topdiv">
<div class="bigdiv">
<p>big div</p>
</div>
<div id="staticcal">
<p>staticcal</p>
</div>
<div id="staticnews">
<p>staticnews</p>
</div>
</div>
CSS:
#topdiv {
display: inline-block;
background-color:#b0c4de;
min-width: 800px;
}
.bigdiv, #staticcal, #staticnews {
position: relative;
float: left;
border: 2px solid #c7930D;
}
.bigdiv {
margin: 10px 0;
width: 335px;
height: 250px;
}
#staticcal, #staticnews {
display: inline-block;
line-height: 175px;
width: 220px;
height: 100px;
margin: 5px;
margin-top: 10px;
margin-right: 0px;
-webkit-border-radius: 4px; /*This will address iOS 1 to 3.X, Android 1.6-2.1, Safari 3 - 4*/
-moz-border-radius: 4px; /*Firefox 1 to 3.6*/
border-radius: 4px; /*IE 9+, Opera 10.5, Chrome, Safari 5, FireFox 4+, iOS 4, Android 2.1+,
}
p {
text-align: center;
}
Related
I have two rectangles with a background effect. On their own, the hover function works well and translates the top div up and to the right, however I soon as I put this code into a flex container, the hover does not work anymore. Anybody know why? Heres the code without the flex container:
body {
padding: 100px;
margin: 0;
}
.box {
width: 200px;
height: 200px;
background-color: black;
border: solid 2px black;
border-radius: 15px;
z-index: -1;
display: inline-block;
}
.box2 {
position: relative;
width: 200px;
height: 200px;
left: 2px;
bottom: 5px;
background-color: white;
border: solid 2px black;
border-radius: 15px;
}
.box2:hover {
bottom: 8px;
left: 4px;
}
<body>
<div class="box">
<div class="box2">
</div>
</div>
<div class="box">
<div class="box2">
</div>
</div>
</body>
Add display: flex; to the body afterwards and the code wont work anymore.
Here is my try, I delete the z-index.
body {
padding: 100px;
margin: 0;
display: flex;
}
.box {
width: 200px;
height: 200px;
background-color: black;
border: solid 2px black;
border-radius: 15px;
display: inline-block;
}
.box2 {
position: relative;
width: 200px;
height: 200px;
left: 2px;
bottom: 5px;
background-color: white;
border: solid 2px black;
border-radius: 15px;
}
.box2:hover {
left: 8px;
bottom: 4px;
}
<body>
<div class="box">
<div class="box2">
</div>
</div>
</body>
I am trying to achieve the box-shadow inside the right-border, currently everything is working fine except the shadow is getting display outside the right border. Following is the js-fiddle sample code I have tried...
http://jsfiddle.net/5y1guk6d/1/
HTML:
<div class="header">
<div class="header-bar">
<h1 class="title">Page title</h1>
</div>
</div>
<div class="main">
<div class="left-bar">
<div class="menu">
Menu Content
</div>
</div>
<div class="content">
Main content area
</div>
</div>
CSS:
.header {
width: 100%;
height: 40px;
top: 0;
color: white;
}
.header-bar {
height: 100%;
overflow: hidden;
background-color: #009BE1;
}
h1.title {
display: inline-block;
font: bold 16px Arial, sans-serif;
margin: 0 5px 0 15px;
position: relative;
top: 25%;
}
.main {
width: 100%;
overflow: hidden;
position: absolute;
top: 48px;
bottom: 0;
}
/* left bar */
.left-bar {
width: 160px;
float: left;
padding:10px;
background-color: #F0F0F0;
height: 100%;
position: relative;
border-right:1px solid #aaa;
box-shadow:5px 0 5px #ccc;
}
.content {
overflow: hidden;
left: 12px;
padding: 5px 17px 5px 5px;
height: 100%;
position: relative;
}
Appreciated your help..
If you want the box shadow to appear inside of the element instead of outside, use inset. Then you want to invert the x-offset so it appears on the right side.
box-shadow:inset -5px 0 5px #ccc;
http://jsfiddle.net/5y1guk6d/3/
Nothing I can find or have tried is working so I hope someone can tell me where I am going wrong. I have a table-like HTML structure with div rows containing only span cells. These in turn can contain either a single span or two rows of spans. Unfortunately, for some reason I've been wrestling with on and off for weeks, the single span cells do not align with the double-row cells.
The minimal HTML is:
<div id="box">
<div id="rowA" class="row">
<span class="container">
<span class="top">A</span>
<span class="bottom">B</span>
</span>
<span class="container">
<span class="single">C</span>
</span>
</div>
<div id="rowB" class="row">
<span class="container">
<span class="top">D</span>
<span class="bottom">E</span>
</span>
<span class="container">
<span class="single">F</span>
</span>
</div>
</div>
with CSS,
body {
font-size: 16px;
}
div#box {
width: 716px;
height: 255px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
}
div.row {
width: 712px;
height: 47px;
padding: 1px;
padding-left: 4px;
margin-left: auto;
margin-right: auto;}
span.container {
display: inline-block;
width: 40px;
height: 40px;
margin-top: 2px;
padding: 1px;
border: 1px solid black;
border-radius: 4px;}
span.top, span.bottom {
display: inline-block;
width: 100%;
height: 50%;
line-height: 20px;
vertical-align: middle;
}
span.single {
display: inline-block;
width: 100%;
height: 100%;
line-height: 40px;
vertical-align: middle;
text-align: center;
}
The double row cells (e.g. <span class="container"><span class="top">D</span><span class="bottom">E</span></span>) display correctly, the single row cells are shifted downwards for some reason. I know that I can use positioning to correct for the problem but I'd like to understand where I am going wrong. It's tested on Chrome and Firefox and alas their inspectors leave me none the wiser.
All contributions very gratefully received!
body {
font-size: 16px;
}
div#box {
width: 716px;
height: 255px;
margin: 10px auto;
}
div.row {
width: 712px;
height: 47px;
padding: 1px;
padding-left: 4px;
margin-left: auto;
margin-right: auto;
}
span.container {
vertical-align:top; /* ADD JUST THIS LINE */
display: inline-block;
width: 40px;
height: 40px;
margin-top: 2px;
padding: 1px;
border: 1px solid black;
border-radius: 4px;
}
span.top, span.bottom {
display: inline-block;
width: 100%;
height: 50%;
line-height: 20px;
vertical-align: middle;
}
span.single {
display: inline-block;
width: 100%;
height: 100%;
line-height: 40px;
vertical-align: middle;
text-align: center;
}
In my HTML I'm trying to align a Title next to the title's Bullet, so that the first line of the title always is next to the bullet, and the second line (if any) doesn't change the title's position - it just trails to the next line.
JSFiddle:
http://jsfiddle.net/Ebqq8/
HML:
<div class="bullet-container">
<div class="bullet-title-container">
<div class="circle-container">
<div class="circle"></div>
</div>
<p class="bullet-title">Short Title</p>
</div>
<div class="bullet-details-container">
<p>Body Text</p>
</div>
</div>
CSS:
.circle-container {
height: 34px;
display: inline-block;
position: relative;
width: 14px;
border: 1px solid blue;
}
.circle {
border-radius: 50% !important;
width: 12px;
height: 12px;
background-color: red;
display: inline-block;
position: absolute;
top: 0px;
/* width and height can be anything, as long as they're equal */
}
.bullet-title {
display: inline-block;
font-size: 16px;
font-weight: bold;
margin-left: 10px;
min-height: 34px;
width: 200px;
margin: 0px;
}
.bullet-title-container {
color: black;
display: inline-block;
position: relative;
width: 250px;
}
.bullet-details-container {
color: black;
}
.bullet-container {
max-width: 600px;
float: left;
text-align: left;
}
What's happening now is that the first line is always too low, and if there are multiple lines, the whole title gets pushed up too high. I thought that aligning two inline-block elements would do the trick, but it doesn't seem to be working. What am I doing wrong?
You could try adding:
position: absolute;
top: 0;
to .bullet-title { }
http://jsfiddle.net/Ebqq8/2/
Please help. I want to achieve that text and button on yellow box be alligned left and right (text on left side - margin 20 px; button on right side - margin 20 px) and menu in footer aligned with yellow box.
I can't add picture, sorry.
Edit: Added JSFiddle - http://jsfiddle.net/wqBEf/
This is my css code:
#page
{
width: 960px;
margin-left: auto;
margin-right: auto;
border: 1px solid red;
background-color: blue;
}
#page > #main
{
border: 1px solid #000;
width: 650px;
margin-left: auto;
margin-right: auto;
background: white;
border-radius: 5px;
margin-top: 20px;
}
#main > #inner
{
margin: 20px;
}
#page-title h1
{
font-size: 24px;
text-align: center;
}
#footer-hotline
{
height: 50px;
background-color: rgb(255,207,0);
border-radius: 5px;
box-shadow: 0px 3px 3px #999999;
margin-top: 20px;
border: 1px solid #000;
width: 650px;
margin-left: auto;
margin-right: auto;
position: relative;
z-index: 2;
}
#footer-hotline > .part
{
float: left; width: 33%;
margin-left: 20px;
line-height: 50px;
font-size: 16px;
font-weight: bold;
}
#footer-hotline > .part input
{
vertical-align:middle;
}
#footer
{
margin-top: -25px;
height: 100px;
line-height: 25px;
background-color: white;
text-transform: uppercase;
border: 1px solid black;
}
#footer > .link
{
float: left;
border-right: 1px solid #000;
margin-top: 50px;
}
#footer > .link > div
{
margin-left: 5px;
margin-right: 5px;
}
And this is my html code:
<div id="page">
<div id="main">
<div id="inner">
<div id="page-title">
<img src="myLogo.png" alt="Schulz logo" />
<h1>Some title</h1>
</div>
<div id="content">RenderBody</div>
</div>
<div class="f-c"></div>
</div>
<div id="footer-hotline">
<div class="part">Hotline: 0800/888 888</div>
<div class="part"><input type="submit" class="button" id="callback-button" value="callback" name="callback-button" /></div>
</div>
<div class="f-c"></div>
<div id="footer">
<div class="link"><div>GTC</div></div>
<div class="link"><div>About</div></div>
<div class="link"><div>Help</div></div>
<div class="link"><div>Language</div></div>
</div>
Thanx for answers, suggestions and comments.
See http://jsfiddle.net/wqBEf/1/ for an update.
Noteworthy changes.
I added left align-left and right align-right classes set for float and for text alignment, respectively.
I set your links to display: inline because it is the easiest way to center a list of items horizontally.
Those were the main two changes. The rest of the changes were just to support the above two, such as removing/adding some margins.
You could use the :first-child pseudo-class for the issue of getting the two items to work together (this will only work if you have only two at any one time). It's also well supported going back to IE7
You also need to implement float:right, direction:rtl, and margin-right:
#footer-hotline > .part
{
float: right; width: 33%;
direction: rtl;
margin-right: 20px;
line-height: 50px;
font-size: 16px;
font-weight: bold;
}
#footer-hotline > .part:first-child
{
direction: ltr;
float: left;
margin-left: 20px;
}
Eli Gassert's answer should suffice for centering the nav
Source: http://jsfiddle.net/YZ2Uz/
Demo: http://jsfiddle.net/YZ2Uz/show