CSS fluid elements running into each other - css

I'm having some trouble with my css and I was gonna post on stackoverflow but I thought maybe this would be the right place to post seeing its strictly a css problem. I have a jquery cycle plugin tor rotate images and I want to have a block of text to the right of the the rotator but I don't want it to run into the rotator and I also would like it to not crop of when the page is shrunk within reason. right now if you pull the browser window in to the left it just slides under the rotator I would much rather the rotator move to the left as well until it can't anymore then the text should start expanding downward if that is even possible. but I cant seem to figure it out.
here is the site http://falconesuits.com/
hdere is the css (well at least the important part)
#story2 {
margin: 100px;
width:300px;
float:right;
color:#FFF;
}
.slideshow {
width:300px;
height:450px;
background: #cc9966; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#cc9966)); /* for webkit browsers */
background: -moz-linear-gradient(top, #fff, #cc9966); /* for firefox 3.6+ */
min-height: 100%;
border:10px;
border-style:groove;
border-color:#939598;
margin-left: auto;
margin-right: auto;
top: 100px;
}

One approach that might help is to restructure your html by putting your story and slideshow in the same div container:
<div id="content">
<div id="story2">...</div>
<div class="slideshow">...</div>
</div>
Then styling #content so that it has the fluid margins instead.
#content {
overflow: hidden;
margin: 0 auto;
width: 650px;
margin-top: 100px;
}
#story2 {
width: 300px;
float: right;
color: #fff;
}
.slideshow {
float: left;
width:300px;
height:450px;
background: #cc9966; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#cc9966)); /* for webkit browsers */
background: -moz-linear-gradient(top, #fff, #cc9966); /* for firefox 3.6+ */
min-height: 100%;
border:10px;
border-style:groove;
border-color:#939598;
}
As for expanding the text downwards, you could try setting your #story width to a percentage instead of a fixed pixel value, I guess.

Related

Making a CSS menu with hover animation

I am making a menu with 2 items per line and I want them to have a background-image and on hover the image will change to other. I was able to do it in chrome, using content in CSS, but Firefox and IE don't support this. Thus it should be made with background-image. The problem of this is that with content I can specify that the buttons will have 35% of the width and height of the left side while making this with background-image is impossible, I need to say specifically that they will have px of height and that will not make it resize when I resize the window. When I resize the window the left side resizes thus what's inside of it resizes automatically because I defined 35% of it. Here is an example code of how I made it (works in chrome, not in firefox and IE). Can someone help me doing this with background-image and still resize the buttons when I resize the window?
https://jsfiddle.net/37qbtwak/
ul.sidebar-menu li a span {
width:35%;
height:35%;
border:1px solid;
}
ul.sidebar-menu li a span#menu_sensor {
content: url('http://4.bp.blogspot.com/-JOqxgp-ZWe0/U3BtyEQlEiI/AAAAAAAAOfg/Doq6Q2MwIKA/s1600/google-logo-874x288.png');
background-repeat: no-repeat;
background-size: 100% 100%;
-webkit-background-size: 100% 100%; /* Safari */
-khtml-background-size: 100% 100%; /* Konqueror */
-moz-background-size: 100% 100%; /* Firefox */
}
With background-image I have to do it like this:
ul.sidebar-menu li a span#menu_sensor {
content: url('http://4.bp.blogspot.com/-JOqxgp-ZWe0/U3BtyEQlEiI/AAAAAAAAOfg/Doq6Q2MwIKA/s1600/google-logo-874x288.png');
background-repeat: no-repeat;
background-size: 100% 100%;
height:100px;
-webkit-background-size: 100% 100%; /* Safari */
-khtml-background-size: 100% 100%; /* Konqueror */
-moz-background-size: 100% 100%; /* Firefox */
}
Best Regards
That is not a valid use of the content property, which is only intended to be used on pseudo elements.
If you set the display property of your spans to inline-block, you can set a height relative to the width using the padding property. Then set the background-size property to contain and center your image(s).
ul.sidebar-menu{
list-style:none;
margin:0;
padding:0;
}
ul.sidebar-menu li{
margin:0 0 50px;
}
ul.sidebar-menu li.sub-menu{
line-height:15px;
}
ul.sidebar-menu li.sub-menu a{
color:#aeb2b7;
margin-bottom:0 20px 30px 10px;
outline:none;
text-decoration:none;
transition:all .3s ease;
}
ul.sidebar-menu a span {
border:1px solid;
display:inline-block;
padding:0 0 12.25%;
width:35%;
}
#menu_sensor{
background:url('http://4.bp.blogspot.com/-JOqxgp-ZWe0/U3BtyEQlEiI/AAAAAAAAOfg/Doq6Q2MwIKA/s1600/google-logo-874x288.png') center center no-repeat;
background-size:contain;
}
#menu_sensor:hover,#menu_sensor:focus{
background-image:url('http://www.webyposicionamientoseo.com/base/ui/images/blog/27-google-hummingbird.jpg');
color:#fff;
}
<ul class="sidebar-menu" id="nav-accordion">
<li class="sub-menu">
<span id="menu_sensor"></span>
</li>
</ul>

Is it possible to use a gradient over a css background image?

I am trying to get a div to have a blue background image which is 500px wide. I then am trying to get the gradient to be white at the very left of the div and as it goes right the background image is slowly visible
This css code will be useful to make it gradient
.gradient {
width: 200px;
height: 200px;
background: #999; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ccc, #000); /* for firefox 3.6+ */
}
Use the above css in html using class
<div class="gradient">
gradient box
</div>
I actually just posted something similar on another question, but it applies in this case as well. Here it is in action:
http://sassmeister.com/gist/3528cb23d3e831231949
And the CSS to achieve this effect:
.hero {
width: 100%;
height: 500px;
background: url("http://placesheen.com/1200/500") center center no-repeat;
background-size: cover;
}
.hero:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 508px;
background-image: linear-gradient(rgba(255, 255, 255, 0.2), white);
}
Of course be sure to add the correct vendor-prefixes so that it is cross-browser compatible. And if you wanted to change gradient directions you would change the gradient values.
The html:
<div class="hero">
You could put content here if you want
</div>
More on gradients:
http://www.w3schools.com/css/css3_gradients.asp

CSS fading top and bottom "borders"

Take a look at this : http://jsfiddle.net/wjhnX/
I achieved it with this CSS :
background-image: radial-gradient(#CCC, #FFF), radial-gradient(#CCC, #FFF);
background-size: 2px 100%;
background-position: 0 0, 100% 0;
background-repeat: no-repeat;
Is this possible to do but the simulated borders would be top and bottom, not left and right ?
Thanks ahead !
Do you want something like this?
Demo (Some breathing space for your content, I've used margin there, just make sure that it will apply to both, :before as well as :after, so if you want to separate, declare margin separately for each, p.s - I've made colors lil lighter)
/* Using only background gradients */
.one {
width: 400px;
padding: 20px 25px;
margin: 40px auto;
}
.one:before, .one:after {
content: "";
height: 1px;
/* I've removed the vendor prefixes, if you are looking to support older browsers
then refer to older version of this answer.
*/
background: linear-gradient(to right, rgba(0,0,0,0) 0%,rgba(147,147,147,1) 50%,rgba(0,0,0,0) 100%);
display: block;
margin-bottom: 10px;
margin-top: 10px;
}
Explanation:
I've used :before and :after pseudo having content: "", so it creates a block, you can say a virtual block inside the element... and which is further set to display: block, just make sure you use block there else margins and height will have no effect.. and last but not the least am using gradients with rgba to control the alpha/opacity of the gradient which will fade on both ends
you can make it with a seperator as well.
LIVE DEMO
.seperator
{
width: 400px;
height: 2px;
margin: 30px;
background-image: radial-gradient(#CCC, #FFF), radial-gradient(#CCC, #FFF);
background-position: 0, 100%, 0, 100%;
}
.one {
width: 400px;
height: 140px;
margin: auto;
}

IE8 Sticky Footer Problems

If you view this in Firefox, you'll see that the bottom footer stays right with the window as you resize, move, etc. It also starts right at the bottom without a scrollbar. However, in IE8 I can't get it to sit at the bottom at the beginning OR move with the window, and probably a number of other issues. I got the code from this site, and it says it's IE compatible, so I must be doing something wrong. I had to alter the code a bit to fit my situation, but here's the IE specific css:
* {
margin: 0;
}
#container{
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -30px;
}
#footer, .push{
height: 30px;
width: 100%;
background: -moz-linear-gradient(top, #565656, #303030);
background: -webkit-gradient(linear, left top, left bottom, from(#565656), to(#303030));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#565656', endColorstr='#303030');
text-align:center;
font-family: loginfont;
font-size:13px;
color: #fff;
padding-top:5px;
clear: both;
}
Can anyone tell me what's going wrong? I'm absolutely clueless at this point. I hate IE...
I'm not sure, but it can be the padding-top:5px; which is causing the problem. Try changing the margin: 0 auto -30px; to margin: 0 auto -35px; and see if that helps.
In your #container add <div class="push"></div> and add position:relative; to #container as negative margin will not work on static positioned elements.

Two div columns. Dynamic width of one

What i am trying to achieve, is get to divs, next to each other. One would be menu, 150px width, on the left of the screen, and second one, should fill rest of container.
Thats what i came up with:
http://jsfiddle.net/Ln49F/3/
But, the contend div is also "under" menu, and working with text, moving it to right a little is impossible. Is it possible, to make div "content" to be wide for "100% - 150px" somehow, and be placed next to the menu div?
To achieve something like that:
http://jsfiddle.net/Ln49F/4/
Float left, puts the div "next to" menu div, and padding works well, but i dont know how to make it to be wide for the rest of the container div.
Take out the width:100% (just leave it to auto, which is default) and use this:
div.content{
margin-left:150px;
background: green;
}
jsfiddle.
Write like this:
CSS
.wrapper{
overflow:hidden;
padding-bottom:10px;
}
.first{
float:left;
height:200px;
width:150px;
background:red;
}
.second{
overflow:hidden;
height:200px;
background:green;
}
HTML
<div class="wrapper">
<div class="first">first</div>
<div class="second">second</div>
</div>
Check this http://jsfiddle.net/TbRuB/10/
OR
You can also achieve this with display:table property but it's work till IE8 & above.
Check this http://jsfiddle.net/TbRuB/12/
You can view your first fiddle, but updated to work according to your spec, here: http://jsfiddle.net/ramsesoriginal/Ln49F/12/
This works by specifying the right margin on the second div, and simply leaving the width on auto.
the HTMLis unchanged:
<div class="container">
<div class="menu">Menu to the left</div>
<div class="content">Content of site<br>x<br><br><br><br><br></div>
</div>
And the CSS is pretty similar to yours:
div.container{
width: 90%;
height: 150px;
background: red;
}
div.menu{
width: 150px;
height: 100px;
float: left;
background: blue;
}
div.content{
margin-left: 150px;
background: green;
}
I took away the width: 100%; from div.content and replaced it with margin-left: 150px;
As you can see, you nearly had it right!
EDIT: BONUS: (fake) Equal height columns!
I updated the fiddle with some code to create "faux columns" with CSS3, so that it looks as if both divs are expanding down to the bottom of the container. You can see it here: http://jsfiddle.net/ramsesoriginal/Ln49F/13/ I don't know if you actually need it, but it's a common requirement for this kind of scenarios.
I simply placed a gradient background on the container, with a single hard stop in the middle:
background: linear-gradient(left, blue 150px, green 150px);
And then I expanded that with various vendor prefixes:
background: -moz-linear-gradient(left, blue 150px, green 150px); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(150px,blue), color-stop(150px,green)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, blue 150px, green 150px); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, blue 150px, green 150px); /* Opera 11.10+ */
background: -ms-linear-gradient(left, blue 150px, green 150px); /* IE10+ */
background: linear-gradient(left, blue 150px, green 150px); /* W3C */
I don't know if you need it, but sometimes this can be very useful!
Use simple solution
<div class="container">
<div class="menu">Menu to the left</div>
<div class="content">Content of site<br>x<br><br><br><br><br></div>
</div>
div.container{
width: 90%;
height: 150px;
background: red;
}
div.menu{
width: 150px;
height: 100px;
float: left;
background: blue;
}
div.content{
background: green;
margin-left: 150px;
}
http://jsfiddle.net/thirtydot/Ln49F/16/
div.container{
width: 90%;
background: red;
display: inline-block;
}
div.menu{
width: 150px;
float: left;
background: blue;
display: inline;
}
div.content{
display: inline;
float: left;
width: 65%;
background: green;
padding-left: 20px;
}
look at this
i hope this helps
Check this fiddle out. Basically, using box-sizing, some padding and a negative margin, you can line the two elements up to the top of their container. and have the content box stretch the expanse of its parent.

Resources