I am trying to display dynamic generated div's horizontally with scroll bar. There can be n number of div's.
Below is my Code:
HTML (index.html)
<div style="width:100%;float:left;" id="old">
<div>
<h1>First Div</h1>
<div id="R1">
<h1>First Div Internal</h1>
<a id="R1_index" class="close_page" href="javascript:void(0)">Close</a>
</div>
</div>
<div>
<h1>Second Div</h1>
<div id="R2">
<h1>Second Div Internal</h1>
<a id="R2_index" class="close_page" href="javascript:void(0)">Close</a>
</div>
</div>
</div>
I follow this link for solution.
But when dynamic div's load, structure looked messed up.
Here is the messy look:
HTML (index.html)
<div style="width:100%;float:left;" id="old">
<div id="items">Missing Internal Content</div>
<div id="items">Missing Internal Content</div>
</div>
Please help me guys.
i imagin the problem is that the div's in the container (id="old" in your example) are not next to each other, but instead beneath.
if that is your problem, you add the following styles to your container:
#old {
overflow: auto;
white-space: nowrap;
}
and make the childern-divs inline-block elements:
#old > div {
display: inline-block;
}
then it should work as expected. see the working solution:
* {
padding: 0;
margin:0;
}
#container {
width: 300px;
height: 100px;
overflow: auto;
white-space: nowrap;
}
.element {
display: inline-block;
}
.box {
width: 100px;
height: 100px;
background: lightgrey;
}
<div id="container">
<div class="element">
<div class="box">
<h1>1</h1>
</div>
</div>
<div class="element">
<div class="box">
<h1>2</h1>
</div>
</div>
<div class="element">
<div class="box">
<h1>3</h1>
</div>
</div>
<div class="element">
<div class="box">
<h1>4</h1>
</div>
</div>
<div class="element">
<div class="box">
<h1>5</h1>
</div>
</div>
<div class="element">
<div class="box">
<h1>6</h1>
</div>
</div>
<div class="element">
<div class="box">
<h1>7</h1>
</div>
</div>
<div class="element">
<div class="box">
<h1>8</h1>
</div>
</div>
</div>
otherwise please provide a better example/description of what the problem exactly is.
Related
Here is my html:
<div class="main">
<div class="parent">
<div class="child">
<span></span>
<label></label>
</div>
<div class="child2">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span></span>
<label></label>
</div>
<div class="child2">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span></span>
<label></label>
</div>
<div class="child2">
// some html content
</div>
</div>
</div>
now i want to apply border-right property to the child class.
I did:
.parent.child:not(:last-child) {
border-right: 1px solid tpBorderColor;
padding-right: 20px;
}
I also tried:
.parent.child {
border-right: 1px solid #e9e9e9;
}
.parent.child-child {
border:none;
}
Both of them results in not showing the border to any of the divs.
any idea how to work this?
Not sure if it was you are looking for but, since your .child element is next to a .child element in the dom you can simply use something like this:
.child + .child {
border-left: 1px solid currentColor;
padding-left: 20px;
}
This affects the .child that is next to a .child
.child + .child {
border-left: 1px solid currentColor;
padding-left: 20px;
}
<div class="main">
<div class="parent">
<div class="child">
<span>343</span>
<label>sfs</label>
</div>
<div class="child">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span>sfa</span>
<label>afa</label>
</div>
<div class="child">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span>343</span>
<label>asfdfaf</label>
</div>
<div class="child">
// some html content
</div>
</div>
</div>
Your code is almost there. Just made some minor changes.
Try this.
.parent .child:not(:last-child) {
border-right: 1px solid red;
padding-right: 20px;
}
.child {
margin-bottom: 30px;
}
<div class="main">
<div class="parent">
<div class="child">
<span>343</span>
<label>sfs</label>
</div>
<div class="child">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span>sfa</span>
<label>afa</label>
</div>
<div class="child">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span>343</span>
<label>asfdfaf</label>
</div>
<div class="child">
// some html content
</div>
</div>
</div>
Based on the code you supplied, any borders applied to <div class="child"> would not be visible because there is no content within the HTML elements.
With that being said, you also would need to update your CSS.
This is because currently, you are styling all elements with class="parent child" but none of your elements have both selectors in a single class. Because the classes (parent > child) are nested you will need a space between them in your CSS file (see below).
.parent .child:not(:last-child) {
border-right: 1px solid tpBorderColor;
padding-right: 20px;
}
For example,
<style>
.parent .child:not(:last-child) {
border-right: 1px solid #000;
padding-right: 20px;
}
</style>
<div class="main">
<div class="parent">
<div class="child">
<span></span>
<label></label>
</div>
<div class="child2">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span>// some html content</span>
<label></label>
</div>
<div class="child2">
// some html content
</div>
</div>
<div class="parent">
<div class="child">
<span>// some html content</span>
<label></label>
</div>
<div class="child2">
// some html content
</div>
</div>
</div>
Notice how the first instance of the styled element is not rendered in the above example because there is no content.
<div class="parent">
<div class="child">
<span></span>
<label></label>
</div>
<div class="child2">
// some html content
</div>
</div>
I want my div and navbar's width stretch all the way to the right 100% but for some reason, it stops right before it reaches it. I've added screen cap of what I see
screencap
css
.section2{
font-size: 2em;
background-color: white;
width: 100%;
height: 100%;
opacity: .75;
}
HTML
<section class="section2">
<div class="row" align="center">
<div class="col-md-12">
text
</div>
<div class="row" style="font-size:.75em" >
<div class="col-md-12" >
</div>
</div>
</div>
<br><br>
<div class="row" align="center">
<div class="col-md-12">
text
</div>
<div class="row" style="font-size:.75em">
<div class="col-md-12">text
</div>
</div>
</div>
<br><br>
<div class="row" align="center">
<div class="col-md-12">
text
</div>
<div class="row" style="font-size:.75em">
<div class="col-md-12">Text
</div>
</div>
</div>
</section>
I found the solution body and html should be set to 0 margin and padding
html, body {
margin:0;
padding:0;
}
I think the parent of your section2 isn't at 100% of your screen.
I can't get the colors to show up in chrome. I've tried switching the order of the files in <link> just in case that is the problem. I don't see any reason why the colors are'nt showing up in chrome.
.header {
background-color: white;
}
.body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container"></div>
</div>
Your .body class DIV doesn't have any content. If you put some text into it, you see the blue background:
(and since the browser windows background is white by default, you won't see the white background on your .header DIV...)
.header {
background-color: white;
}
.body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container">Here is some content</div>
</div>
.header {
background-color: white;
}
body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container"></div>
</div>
I assume you are trying to change the entire page background color which needs to be done with a body { ... } selector not .body{ ... } as in this sample.
However, if the goal is to target the with a class of body your CSS is correct but there is nothing inside for content so it has a height of 0 by default. Add content like Johannes mentioned and it should work for you.
I have to create an IRC-like web chat (latest messages have to appear at the bottom of the parent container).
Here's my (unsuccessful) attempt:
.inner-conversation-container {
height: 100px;
position: relative;
overflow: hidden;
width: 500px;
}
.conversation-stream-container {
max-height: 100px;
position: absolute;
bottom: 0;
overflow: auto;
width: 100%;
}
<div class='inner-conversation-container'>
<div class='conversation-stream-container'>
<div class='conversation-item'>
<div class='conversation-message-part' msg-id='137'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='138'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='139'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='140'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='141'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='142'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='143'>
<div class='center-part'>Content</div>
</div>
<div class='conversation-message-part' msg-id='144'>
<div class='center-part'>The latest message that needs to be in the bottom</div>
</div>
</div>
</div>
</div>
The div with msg-id="144" needs to be visible and aligned to the bottom.
jQuery aided solution
Using your HTML mark-up:
<div class='inner-conversation-container'>
<div class='conversation-stream-container'>
<!-- A single item -->
<div class='conversation-item'>
<!-- Message parts -->
<div class='conversation-message-part' msg-id='125'>
<div class='center-part'>test 9</div>
</div>
...
<div class='conversation-message-part' msg-id='143'>
<div class='center-part'>no, it's not</div>
</div>
<div class='conversation-message-part' msg-id='144'>
<div class='center-part'>latest needs to be in the bottom</div>
</div>
</div>
</div>
</div>
you can simplify your CSS as follows:
.inner-conversation-container {
height: 200px;
width: 500px;
border: 2px solid lightgray; /* for demo only */
overflow: auto;
}
.conversation-stream-container {
background-color: yellow; /* for demo only */
}
and set the scroll bar position using jQuery:
$('.inner-conversation-container').scrollTop(
$('.inner-conversation-container')[0].scrollHeight
);
Demo fiddle: http://jsfiddle.net/audetwebdesign/FW6Y5/
I am trying to keep my footer at the bottom of the page. The first way I tried it, the footer would be above the bottom of the page and the background would show. This was with position:static; (like the following image)
The second way I tried is with an absolute footer. This puts the footer at the bottom of pages where there isn't enough content to scroll but on pages with the scroll, it sits at the bottom of the window when it loads and is on top of content.It is not the bottom of the page.
Here is my current code:
<div id="container">
<div id="content">
<div id="slideshow"></div>
<div id="clear"></div>
<div id="boxes">
<div id="box">
<div id="boxheader"></div>
<div id="box1" class="box"></div>
</div>
<div id="box">
<div id="boxheader"></div>
<div id="box2" class="box"></div>
</div>
<div id="box">
<div id="boxheader"></div>
<div id="box3" class="box"></div>
</div>
</div>
<div id="clear"></div>
</div>
</div>
<div id="footer">Content</div>
Here is the CSS
div#container{
position:relative;
margin: 4px;
}
#boxes{
width: 960px;
margin: 50px auto 0px auto;
}
#footer {
clear: both;
margin-top: 50px;
bottom: 0;
left: 0;
height: 200px;
background-color: #fff;
width: 100%;
}
Please let me know if you need any additional information.
set
html, body {
height: 100%;
}
wrap the entire content before the footer in a div.
.wrapper {
height:auto !important;
min-height:100%;
}
You can adjust min-height to your liking based on how much of the footer you want to show in the bottom of the browser-window. If set it to 90%, 10% of the footer will show before scrolling.
So in your example
<body style="height: 100%">
<div id="container" style="min-height: 90%; height: auto !important;">
<div id="content">
<div id="slideshow"></div>
<div id="clear"></div>
<div id="boxes">
<div id="box">
<div id="boxheader"></div>
<div id="box1" class="box"></div>
</div>
<div id="box">
<div id="boxheader"></div>
<div id="box2" class="box"></div>
</div>
<div id="box">
<div id="boxheader"></div>
<div id="box3" class="box"></div>
</div>
</div>
<div id="clear"></div>
</div>
</div>
<div id="footer">Content</div>
I've used the method described in the article liked below many times, and have had no problems with it:
http://ryanfait.com/resources/footer-stick-to-bottom-of-page/
Hope it helps!