I have a that contains two nested div's. One of the nested div's contains a javascript graph.
When the page renders, the javascript graph is at an incorrect location, outside of the 's area. Does anyone know what I am doing wrong?
Here are the css:
#graph_container{
width: 75%;
margin: 0 auto;
background-color: #FFF;
padding: 20px 40px;
border: solid 1px black;
margin-top: 20px;
}
#graph{
width: 75%;
margin-top: 20px;
}
#car_select{
width: 25%;
margin: 0;
background-color: #FFF;
}
And Rails.ERB file
<div id="graph_container">
<div id="car_select">
# this part is at the correct location...
</div>
<div id = "graph">
# this is showing up outside of graph_container
<script type="text/javascript" language="javascript">
//<![CDATA[
var chart = new AnyChart('/AnyChart.swf');
chart.width = 500;
chart.height = 500;
chart.setXMLFile('car_info.xml');
chart.write();
//]]>
</script>
</div>
</div>
You can get the <div>s in the right place with 2 fixes:
Float them left and right respectively.
Add a clearing element below them so they stay inside the #graph_container.
You can see it in action here.
If that doesn't work, your Javascript may be setting the position on the graph it creates to absolute. In this case, add position: relative; to your #graph container. This will cause any absolutely positioned children (i.e. the graph) to use it, rather than the document, as its coordinate system.
Have you tried making the positioning absolute?
http://cssdesk.com/EUYhZ
Pat and Danny's suggestions were valid and important for the output. But neither fixed my problem, what turned out to be the issue was actually the Javascript code. I didn't set where the code was suppose to be inserted.
Simply placing within the element I wanted DID NOT work. In my case, what I needed to do was fill in chart.write() with chart.write('graph'), so that the script would insert itself in the part of the html.
Related
I am programming a simple movieDB app with Ionic. A part of it is listing actors, who play in a movie as a scrollable vertical card list. I am using good ol' divs and custom CSS.
This is how it looks like in a browser (Firefox 38 on Mac): this is the DESIRED behavior
however when I emulate it on iOS (iOS 7.1.1 on iPad) I get this:
It is scrollable, but the divs overlap. They are collapsed.
You can find my CSS code below. I believe that I have tried a combination of every -webkit tag out there and I still can't get it to work.
Any help greatly appreciated :)
#actorsBox{
display: flex;
display: -webkit-flex;
flex-direction: row;
-webkit-justify-content: space-between;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
align-items: center;
#actor {
height: 30vh;
width: 15vw;
margin-left: 2vw;
padding-top: 12vh;
border-radius: 5px;
text-align: center;
background-color: cornflowerblue;
}}
UPDATE 7:45 GMT 25.6.2015
Thanks to COOOL's answer I am able to track the origin of this behavior, so I am updating the question:
In browsers, overflow-scroll extends the flexbox to accomodate all items with their original widths. However with the current code, iOS just squeezes them all in the original dimensions of the flexbox. If I were to put anything more than 100px they would overlap again (see the code below).
#actorsBox{
display: flex;
display: -webkit-flex;
flex-direction: row;
-webkit-justify-content: space-between;
overflow-y: scroll;
overflow-scrolling: auto;
-webkit-overflow-scrolling: touch;
align-items: center;
.actor {
height: 30vh;
width: 100px;
min-width: 100px;
However if I set width of #actorsBox to something big (say 2000px) the items are spaced out nicely again.
It seems to me that -webkit-overflow-scrolling is the cause of the issue. Does anyone have some experience with this?
Well, firstly your using a div #id for an area you should be using a .class
a .class is for selecting multiple instances as an #id is for one unique instance.
It looks like you have #actor as the selector of the problematic content. And it looks like your width is being ignored.
You can firstly try using px or % (instead of vw) where you have this: width: 15vw;
Or define a min-width for the actor boxes.
.actor { // firstly change to a class
height: 30vh;
width: 15vw; // mobile browser could dislike this, if below doesn't work try using % or px
min-width: 20px; // or whatever is relevant, may require some testing
/// the rest of your cool styles
}
Update: (re: your comment)
If 2000px on #actorsBox responded well, then you may need to add a min-width there as well. (or at-least define a width)
#actorsBox{
// all your previous styles
width: 1000px; // hows it gonna know when to overflow, bro?
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
// I would add min-width in px then width 100% and a max-width in px
// but declaring a width here is all you need
align-items: center;
}
In any case you need a width defined where you have an overflow-scroll defined. This is likely your issue; if the above still doesn't work try also adding this position:relative; to assure .actor is relative to this as a wrapper
http://i.stack.imgur.com/bbxDC.png
as you can see labels of selects and buttons not same line.
Which css i overload or change ?
The icons at left and right of the buttons/selects are causing the center alignment to use a different center. You can solve this with some CSS:
.ui-btn-inner{
padding-right: 40px;
padding-left: 40px;
}
.ui-select .ui-btn-icon-right .ui-btn-inner{
padding-right: 40px;
padding-left: 40px;
}
Without the CSS: DEMO
With the CSS: DEMO 2
Depending on the exact elements and icon-positions you are using, you may need some more CSS to equalize padding on each side of the centered text.
Okay so I have these divs called "latestWorkTitle" which are positioned absolute and are placed on top of the corresponding image to show its title.
However, I can't get this properly to work. The titles don't show at the corresponding image and when I resize my browser window everything shifts and so on.
I tried creating this jsbin http://jsbin.com/uhoxef/1 with a part of my code to illustrate how it should look like and what is going wrong. Even all the titles go on top of each other in the code while they should be on top of the corresponding images... I'm just basically totally lost at this.
I think the HTML was confusing itself. I also made the thumbnail class the relative layer. HTML renders as we read, from left to right. So putting the title before the image causes the image to show on top and cover the text.
HTML:
<div class="thumbnail">
<a href="portfoliodetail.php?id=10">
<img src="http://www.hlnarchitects.com/img/plain_red.png" />
<div class="latestWorkTitle">title1</div>
</a>
</div>
CSS:
.thumbnail {
position: relative;
overflow: hidden;
float: left;}
.portfolioOverview img {
width: auto;
height: auto;}
.latestWorkTitle {
text-align: right;
font-size: 11px;
text-transform: uppercase;
background: yellow;
position: absolute;
padding: 6px;
top: 0;
left: 0;}
For this to work, each thumbnail class needs to be the relative start for each individual layer. So the thumbnail class is set to relative.
Any object set to absolute (.latestWorkTitle) within this layer will start from the top and left position of the relative object.
You'll need to adjust some details to taste but I hope this helps.
When I set a maximum scale and when I rotates orientations back and forth, the web page isn't centered on the phone.
So using this code
<meta name="viewport" content="width=device-width; initial-scale=0; maximum-scale=2;">
How can I mimic the CSS effect of margin: 0 auto;.
For people arriving here from Google, you should also look at the following page on Apple[1].
The viewport tag is quite helpful.
[1]: http://developer.apple.com/library/IOS/#documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html Using the ViewPort
You will need to have a wrapper inside of another wrapper to get this to work. The outside one will have the following CSS:
#wrapper {
min-width: 320px;
max-width: 480px;
}
And the inside one will have the following:
#inside-wrapper {
min-width: 300px;
max-width: 460px;
margin: 0 auto;
}
You can still use margin: 0 auto;
n00b question alert, but I've been struggling for a few days with this one and have searched in vain for the solution in other posts!
I have a horizontal menu that has padding either side of the text such that the items appear separated. However upon replacing the text with sIFR, the padding doesn't appear, and thus the items all look like they are separated by only a space (and it looks like they are all within the same flash movie). I need to separate them!
The css is set as so:
#menu a {
height: 30px;
padding: 8px 38px;
letter-spacing: -1px;
text-decoration: none;
font-size: 22px;
color: #000000;
}
I've tried putting the same in the sifr.css at the bottom:
.sIFR-active #menu {
padding: 8px 38px;
visibility: hidden;
font-family: Verdana;
font-size: 19px;
text-decoration: none;
}
That doesn't work. I've tried putting this into the sIFR.replace function too, as well as a few other directives like tuneWidth... I haven't managed to get this working no matter what I try! Can anyone help?
If you want to have a look at an example page go here: http://www.ak40.co.uk/invitation.htm
Many thanks in advance.
Kev
Put some margin around the Flash movies instead.