This is what I want the chicklet box to look like:![]1
For some reason I can not use negative margins to get the twitter image to go to the center of the box. Is there something wrong with my parent-child relationship?
My css is in an external sheet, but here it is:
<style type="text/css">
#chicklet_container {
margin:20px auto 0px auto;
width:540px;
height:215px;
}
#chicklet_box {
margin:0px 0px 10px 0px;
width:190px;
height:160px;
border-style:solid;
border-width:33px 5px 5px 5px;
border-color:#45BA88;
position:relative;
}
#chicklet_box2 {
margin:-30px 0px 10px 0px;
width:190px;
height:160px;
border-style:solid;
border-width:0px 0px 30px 0px;
border-color:#3f4040;
}
#chicklet_text {
text-align:center;
margin:-196px 0px 0px 0px;
color:#FFF;
width:190px;
font-family:"Verdana, Geneva, sans-serif";
font-size:27px;
line-height:20px;
}
#chicklet_text2 {
text-align:center;
margin:139px 0px 0px 0px;
color:#FFF;
width:190px;
font-family:"Proxima, Nova, Ultralight";
font-size:26px;
line-height:20px;
}
#chicklet_box img {
margin:-250px 0px auto 5px;
}
</style>
Here is the html:
<div id="chicklet_container">
<div id="chicklet_box">
<div id="chicklet_box2">
</div>
<div id="chicklet_text">Follow Me</div>
<div id="chicklet_text2">#soandsoandso</div>
<img src="images/twitter.jpg" alt="">
</div>
</div>
Why are you using so much margin to align the twitter bird image or text. Use as low margins as possible. Instead this, try using that image position:absolute; and top ,left properties. It'll be more clean. But one thing to remember if you are using absolute position for an element ,check if its outer or parent element is positioned or not, if it is not then things may go worse and that child element might go somewhere else.
Negative margins are not a hack - W3C even says: "Negative values for margin properties are allowed..."
Read More: http://www.smashingmagazine.com/2009/07/27/the-definitive-guide-to-using-negative-margins/
I do agree in this case though they may be over-emphasized.
Why do you have Chicklet Box 2 inside of Chicklet Box 1? I'm assuming each box represents an icon... am I wrong?
Related
Have a rather simple spoiler code for my website. It has sort of large border radii, which is fine when the element is expanded, but not so much when shrunk. Is there some way I can make the bottom border radii just go to 0px when its shrunk, or is that just not a thing with CSS?
And I would, yes, like it to be a CSS solution. It's no real problem for me to have to shrink the border radius, but y'know, might as well try to not if its possible.
I am not sure how to make the javascript my code uses work on stackoverflow (it just gives me errors), so here is a screenshot of what it looks like expanded.
.panel {
background-color: #F9F9F9;
border: 1px solid gray;
border-radius: 22px 22px 10px 10px;
font-family:arial;
}
.panel>h3 {
font-size:14px;
background-color:#820D1A;
color:#ededed;
border-bottom:1px solid #000;
text-align:left;
padding:4px;
padding-left:20px;
margin:0px;
border-radius: 21px 21px 0px 0px;
}
.panel>div {
padding:4px;
}
.panel>div:after {
display: block;
clear: both;
}
<div class="panel">
<h3>(PARAM1)<span style="font-size:10px;margin-left:6px;">(Click to toggle)</span></h3>
<div style="display:none">(PARAM2)</div>
</div>
.panel {
background-color: #820D1A;
border: 1px solid gray;
border-radius: 22px 22px 10px 10px;
font-family: arial;
}
.panel>h3 {
font-size:14px;
color:#ededed;
text-align:left;
padding-left:20px;
margin:5px;
}
.panel>div {
padding:4px;
background-color: #FFF;
}
.panel>div:after {
display: block;
clear: both;
}
<div class="panel">
<h3>(PARAM1)<span style="font-size:10px;margin-left:6px;">(Click to toggle)</span></h3>
<div style="display: none">(PARAM2)</div>
</div>
Does this look closer to what you are trying to achieve? There were two padding rules on the h3 and I was wondering why you have a background on there as well? Would this not work with your Javascript?
Eh, after messing around I came to the answer that no, it isn't possible. I just resolved to decrease the top border radii by 5 pixels (making them 17px) so that it'd look normal open or closed.
Thank you to everyone who put forth some help, though~
I'm experimenting Foundation and I wanted to build a template with full width rows. Everything is working fine on Firefox and Chrome but full width is not working on IE (I'm using IE 11 so I guess previous versions are also impacted).
My html:
<div class="row fullWidth-3">
<div class="small-12 columns navigation-3">Navigation</div>
<div class="small-12 columns advertising-3">
Advertising
<div class="contentWidth-3">
<div class="small-12 columns">TEST</div>
<div class="medium-4 columns">TEST</div>
<div class="medium-8" columns">TEST</div>
</div>
</div>
</div>
and now the CSS part:
.fullWidth-3
{
width: 100%;
margin-left: auto;
margin-right: auto;
max-width: initial;
}
.contentWidth-3
{
width: 85%;
margin:0 auto;
color:#000;
background-color:#FFF;
-webkit-box-shadow: 0px 0px 8px -3px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 8px -3px rgba(0,0,0,0.75);
box-shadow: 0px 0px 8px -3px rgba(0,0,0,0.75);
}
.navigation-3
{
background-color:#000;
color:#FFF;
margin:0px;
padding:5px;
box-sizing:border-box;
font-size:19px;
}
.advertising-3
{
background-color:#999;
color:#FFF;
margin:0px;
padding:5px;
box-sizing:border-box;
font-size:19px;
}
IE seems to be limited around 1000 pixels width while Firefox and Chrome displaying a full width div as expected.
I'd like to keep the foundation CSS clean. Do you have any idea of how I could solve this?
additional note:
- with this alone, it doesn't work either
.fullWidth-3
{
width: 100%;
}
Thanks
Laurent
As mentioned in the comments by #GL.awog
Class "row" has a general max-width limit of 62.5rem for all browsers, remove max-width:initial from .fullWidth-3 and you'll see the same behaviour as in IE.
Rather set max-width:100% than leave initial thing, that is not consistent across browser
I have a small text in the footer. The text is aligned to right but i want the text to move up slightly? how can I do that? my code
#foot tag {
width:1000px;
height:30px;
padding:10px;
border:5px solid white;
margin:0px;
text-align:right;
padding-top: 10px;
}
#foot tag {
width:1000px;
height:30px;
padding:10px 10px 20px 10px;
/* You can adjust the above 4 values to add padding to top, right, bottom and left */
border:5px solid white;
margin:0px;
text-align:right;
}
You can do a couple things, it's tough to say without seeing the live site.
1) decrease the top padding by changing:
padding: 5px 10px 10px 10px;
2) use a negative top margin:
margin: -5px 0 0 0;
You can try this. Top and left css property will move you p in parent div
<div style="position: relative"><p style="position: absolute; top: 1px"></p></div>
I have a parent div with a child div inside it (the child div acts as a pop up menu). When the child div pops out it has a tiny space so that it's not lined up with the left of the parent div.
here's the styles:
.ButtonContent
{
display:none;
border: solid 1px black;
width:275px;
position:absolute;
left:0;
margin:0px;
padding:0px;
float:left;
background-color:#FFF;
border-radius:0 0 4px 4px;
}
.Button
{
margin:0px;
padding:0px;
border: solid 1px black;
border-radius:4px 4px 4px 4px;
width:276px;
text-align:center;
position:relative;
}
Here's the HTML:
<div class="Button" id="Button1" >
Add <br />
<div class="ButtonContent" id="ButtonContent1">
Date purchased:
<div class="Date" id="datePurchased1"></div><br/>
Purchase Location:<br />
<input type="text" maxlength="150" /><br />
<a>Add</a>
</div>
</div>
Since you have an absolutely positioned element inside a relatively positioned one with a border, left:0 positions it within the border which makes it look off by a pixel.
Quick fix: make them both the same width and use left:-1px; instead.
http://jsfiddle.net/RtGfc/
It looks to me like you don't need all this CSS to achieve the look you want, maybe a better fix (without touching your HTML):
.ButtonContent
{
border-top: solid 1px black;
background-color:#FFF;
border-radius:0 0 4px 4px;
}
.Button
{
border: solid 1px black;
border-radius:4px;
width:275px;
text-align:center;
}
http://jsfiddle.net/RtGfc/1/
It's two things: the 1px border from the outside <div> and the fact that you chose to put one <div> inside the other.
The 1px border is positioned outside the leftmost mark of left: 0px;. If you remove the border, it works.
Demo: http://jsfiddle.net/MmwYv/
You want .ButtonContent, which is the inner <div>, to be displayed outside .Button, which is the outer <div>. That is going to cause problems, because the inner one is going to be restricted by the measurements of the outer one. If you take .ButtonContent outside, it works too.
Demo: http://jsfiddle.net/NxCp4/
It is my understanding that a display:block will automatically start in a new line. Why do the boxes collapse when a float:left is introduced inside a div with display:block? Here is a fiddle and below the code
#wrapper {
width:300px;
margin:0px auto;
text-align:left;
padding:15px;
border:1px solid #a39b8b;
background-color:#fff;
-moz-box-shadow: 0px 0px 10px #888;
-webkit-box-shadow: 0px 0px 10px #888;
box-shadow: 0px 0px 10px #888;}
#header { width: 100%; display: block; }
#logo { width: 100px; height: 145px; background: #fde; }
#slogan {
display: block; background: #f9ebcd; height: 35px; -moz-box-shadow: 0px 3px 10px #888;
-webkit-box-shadow: 0px 3px 10px #888; box-shadow: 0px 3px 10px #888; border: 1px solid red;
}
.left { float:left;}
<div id="wrapper">
<div id="header">
<div id="logo"class="left">left</div>
</div>
<div id="slogan">slogan</div>
Floats move an element out of the normal flow of the page. If there's nothing left in the flow inside a containing element, it will 'collapse'.
Check the specs for more info.
I recommend you familiarize yourself with clearfix. It makes life easier.
Your example (revised): http://jsfiddle.net/HkHTk/4/
That's just what happens with float.
A common problem with float-based layouts is that the floats' container doesn't want to stretch up to accomodate the floats. If you want to add, say, a border around all floats (ie. a border around the container) you'll have to command the browsers somehow to stretch up the container all the way.
The fix:
#wrapper {
overflow: auto;
}
Demo: http://jsfiddle.net/mattball/CjXNW/
You need to clear your float using the CSS clear property.
What are you trying to do? If you want the slogan box to appear beneath the logo box, you need to add clear:both; to the #slogan code.