I have a page background image that must be aligned precisely in order to coordinate with the background image of a frame (so it looks like the same image over page and frame). Here is what it looks like (note the plant image).
The problem is that the page background image is making the horizontal scroll bar appear. I want the horizontal scroll bar to appear when the window is smaller than the frame (#main_frame), not when the window is smaller than the page background image.
Here is the (SASS) CSS that (I think) is relevant:
#main_frame
-webkit-border-radius: 25px
-moz-border-radius: 25px
border-radius: 25px
-webkit-box-shadow: 10px 10px 10px 0px rgba(0,0,0,0.7)
-moz-box-shadow: 10px 10px 10px 0px #706270
box-shadow: 10px 10px 10px 0px #706270
-webkit-box-sizing: border-box
-moz-box-sizing: border-box
box-sizing: border-box
background-color: white
border-style: solid
border-color: black
border-width: 2px
width: 950px
margin: 50px auto
height: 800px
background: #fff url(../images/plant_white.jpg) 560px -95px no-repeat
#plantBackgroundHolder
width: 1200px
height: 900px
background: #ffc url(../images/plant_yellow.jpg) 690px -40px no-repeat
position: absolute
z-index: -1
top: 0
margin-left: -600px
left: 50%
And the HTML:
<div id="plantBackgroundHolder">
<div id="main_frame">
...
</div>
</div>
I'm pretty sure it's the width of the #plantBackgroundHolder that is causing the horizontal scroll bar to appear; but if I remove that, the background image gets shifted around.
Background information:
The original solution for making a transparent overlay effect
The site with the problem
The repo of the site
Any suggestions would be greatly appreciated!
You're declaring a height here and there on your CSS, you need to remove that, you need to let the height flow freely instead of setting a fixed height. Here are the places i could find:
body { height: 1000px } // remove height, also width!!!
#plantBackgroundHolder { height: 900px } // remove height
Moreover, remove the margin that you have set on the #main_frame id and set it to something like 10px auto 0 to remove the margin you have set on the bottom of the div.
Also, remove this from your html tag, you're forcing the scroll to appear on the page;
html { overflow-y: scroll }
Note: you need to heavily revise your code, you're not properly nesting your divs and you can easily achieve the same effect with less than half of what you have now.
Working to align the two images might keep coming back to haunt you. One approach is to use a single image with a transparent background. PNG's with alpha transparency work since IE6 (more info).
Sandwich the png between the white background behind the content and the border around the content. Here is an example JSFiddle.
/* Container provides (yellow) background behind the image */
#main_frame_container {
position: relative;
border-radius: 25px;
margin: 50px auto;
width: 300px;
background-color: yellow;
}
/* Position the "background" image */
#background_image {
position: absolute;
right: -10px;
top: -10px;
width: 100px;
}
/* Main content over both the (yellow) background and image */
#main_frame {
position: relative;
border-radius: 25px;
border: solid black 2px;
padding: 20px;
}
body {
background-color: pink;
}
Related
I also look at this question IE renders inline-block div differently than FF/Chrome but this cannot help me.
This is the CSS code for my element (in html it's an invisible square link):
#box-scenario {
position: absolute;
margin-top: 43%;
margin-left: 37%;
background-color: rgba(255, 0, 0, 0);
width: 11%;
height: 21%;
display: inline-block; }
The invisible square link is about 200px higher than FF/Chrome positioning.
Here is a Fiddle for you too look at in each browser. I added a parent div with stripes and also added a red outline around the invisible link, so that we would have some reference points.
The invisible square link is about 200px higher than FF/Chrome positioning.
For me, across all the browsers, the link renders at 3.5 bars above the bottom. Where does it render for you?
#parent {
outline: thin solid black;
position: relative;
height: 180px;
width: 180px;
background: repeating-linear-gradient(to top, white, white 10px, yellow 10px, yellow 20px);
}
#box-scenario {
position: absolute;
margin-top: 43%;
margin-left: 37%;
background-color: rgba(255, 0, 0, 0);
width: 11%;
height: 21%;
display: inline-block;
outline: thin solid red;
}
<div id="parent">
<a id="box-scenario"></a>
</div>
Without seeing your entire markup and style sheets. I would suggest, if you haven't done it already, is to reset all padding and margin using:
* {
margin: 0;
padding: 0;
}
It removes all default margin and padding for every object on the page, regardless of the browser. This provides a nice clean slate for design and ensures that all spacing is intentional, explict, and ubiquitous across browsers. There is no reason not to do this.
You can always use -webkit-margin(s) (i.e., before, after, start, end). Same goes for -moz-margin.
I'm trying to make a centered page with a fixed width containing a single element expanding above these borders (as Design element).
In wide viewports it works as expected, but when the window gets smaller than the width of that element it will cut off the left side but will make the page scroll to view the right protrusion.
Is there a way to have both sides equally cut off in small viewports?
#wrapper {
position: relative;
width: 900px;
overflow: visible;
background: #CCC; /*just for better viewing */
padding: 20px 0; /*just for better viewing */
}
#navigation {
position: relative;
width: 950px;
margin: 0 -25px;
text-indent: 25px;
background: rgba(255, 0, 0, 0.6); /*just for better viewing */
<div id="wrapper">
<div id="navigation">
Some Content
</div>
</div>
For the margin, use a percentage instead of px for mobile devices, so it fits the viewport
#wrapper {
position: relative;
width: 110%; /* Change this percentage for more accurate width */
overflow: visible;
background: #CCC; /*just for better viewing */
padding: 20px 0; /*just for better viewing */
}
#navigation {
position: relative;
width: 950px;
margin: 0 -25px;
text-indent: 25px;
background: rgba(255, 0, 0, 0.6); /*just for better viewing */
}
HTML:
<div id="wrapper">
<div id="navigation">
Some Content
</div>
</div>
Also, change the wrapper width to a percentage, if you want that to fit.
A key here may be to remove the navbar from the wrapper and give it a negative top margin and also change the overflow of your body to hidden such as in this Fiddle
I am currently working on a process site for my Web Design I class. Seeing that I have previous knownledge of HTML I didn't want to stick to a generic layout of my site.
That being said I have come across this problem in the past and just can't remember how to fix it.
http://bccvisualdesign.com/art271/simmons/index.html
As you can see if you resize the browser the div doesn't stretch once a scrollbar is introduced. I am wondering if it is my CSS for the div?
div.content{
width: 50%;
margin-left: 25%;
background: #FFF;
position: fixed;
top: 0;
bottom: 0;
padding: 0px 35px 0px;
-moz-box-shadow: 0 0 40px #000;
-webkit-box-shadow: 0 0 40px #000;
box-shadow: 0 0 40px #000;
}
The goal is to have the white div infinitely stretch top to bottom regardless of the scroll or not. Thank you all for your help!
Using position: absolute rather than position: fixed, as in your live example, you can get this to work by removing the bottom position, or changing it to bottom: auto, and setting a min-height: 100% on div.content.
I'm using a slight hack to have diagonal borders between sections on my page (because I couldn't find a different way to make it work), which consists of having a super thick border added to the 'border' divs. It's fine on computers but on phones (all the ones I've tested on) the divs holding the thick borders stick out and you can scroll horizontally into 'empty space' on the page, only seeing the borders sticking out. Does anyone know how to stop this, or suggest a different way to create the diagonals?
The page is responsive and fills the browser window, that's why I needed a huge border size to be sure it'll be there even on HD displays...
.border-black-white {
border-color: transparent transparent #fff #2d2d2d ;
border-width: 0 0 60px 2600px;
border-style: solid;
}
.border-yellow-white {
border-color: transparent transparent #fff transparent ;
border-width: 0 0 60px 2600px;
border-style: solid;
}
section {
width: 80%;
margin: 0 auto;
padding: 3em 10%;
}
Here is a fiddle with all the code: http://jsfiddle.net/UnX72/
Thank you!
Update: I already tried overflow: hidden (or overflow-x:hidden) and it didn't work.
Well i think is not possible to hide the overflow created by a border not even on desktop browsers or at least not in any of the ones i have installed, i've tried a similar approach than yours to test this and also got the same problem, so i think is better to do it with out using borders, so i created a div and placed another one (with a pseudo element) and rotate to get the same effect, so my guess is that this should work just right for what you want, if not at least i hope it gives you another option.
Here is the jsfiddle Demo
Html
<section>
<div>
<p> Section 1</p>
</div>
</section>
<div class="diagonal">
</div>
<section>
<div>
<p> Section 2</p>
</div>
</section>
<div class="diagonal"></div>
<section>
<div>
<p> Section 3</p>
</div>
</section>
<div class="diagonal"></div>
Css
section {
width: 80%;
margin: 0 auto;
padding: 3em 10%;
background: red;
overflow:hidden;
}
.diagonal{
width: 100%;
height: 50px;
overflow: hidden;
position: relative;
}
.diagonal:after{
content: '';
height: 40px;
background: black;
display: block;
position: absolute;
top: -39px;
left: -5px;
width: 200%;
transform: rotate(7deg);
-ms-transform: rotate(7deg);
-webkit-transform: rotate(-2deg);
}
Here you can check the compatibility of the rotate property
http://caniuse.com/transforms2d
Note:
Depending on the size of the container the "diagonal" will need to be offseted to the right position, you can do so using media queries, or javascript.
I have an implementation of a sticky footer. I actually have the "sticky" stuff working. But now I want to add a interior "content-box" div which will span the entire screen.
Please refer to this page.
What is needed to have the white area be the same height as the cyan area?
It's not possible in this setup,
but what you can do is apply a 1px height background image with background-repeat:repeat-y; on the body or parent container, to simulate the white background of the .content-box div(including the left and right borders).
add
background:url(simulatewhitecontainer.png) repeat-y center top;
to div.main
and remove
border-right: 1px solid #B0B0B0;
border-left: 1px solid #B0B0B0;
from div.content-box
Update: Check this fiddle: http://jsfiddle.net/gqSau/ for an example
using the following css for the content
.content {
padding: 0px;
position: absolute;
bottom: 50px;
top: 70px;
right: 0px;
left: 0px;
}