One scroll bar for 2 separate divs - php

I have two DIV's that are side by side. One div is my side bar (Left Of Screen), the other div is my main content (Right Of Screen).
What I'm looking for:
What I want is one visable scroll bar to the far right of the screen. I would like that scrol bar to scroll both left and right div's.
My Problem:
Currently my left sidebar has a tree menu. When I expand my tree menu, I have no scroll bar to scroll down through the side bar content that was expanded. I'm able to add a scroll bar to my side bar, but that looks very ugly. I just want 1 scroll bar on the far right that handles both div's.
Can someone help me on this one?
My index.php file
<?php
include 'sidebar.php';
include 'main_body.php';
?>
My sidebar.php
<?php
echo '<link rel="stylesheet" href="css/style.css" type="text/css">';
echo '<script type="text/javascript" src="js/jquery1_3_2.js"></script>';
include 'function/functions.php';
// Establish a connection to our database
db_connect();
echo'
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".content").hide();
//toggle the componenet with class msg_body
jQuery(".heading").click(function()
{
jQuery(this).next(".content").slideToggle(500);
});
});
</script>
';
echo'<div class="sidebar">';
// Side Bar Start
echo '
<img src="images/hdc_logo.png">
<br>
<br>
<p class="heading"><strong>CUSTOMER</strong></p>
<div class="content">';
//Display all customers from database
query_all_customers();
echo '</div>
<p class="heading"><strong>CABINET</strong></p>
<div class="content">';
// Display all cabinets from database
query_all_cabinets();
echo'</div>
</div>';
?>
My main content area
<?php
ini_set('display_errors', 1);
echo '<div class="main">';
echo'
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here
<br>
<br>
Some data can go here
<br>
<br><br>
<br>
and here
<br>
<br>
and here';
?>
My .css file
.sidebar {
width:200px;
position:fixed;
top:0px;
left:0px;
height:100%;
background-color:#54524F;
/*overflow-y: scroll;*/
}
.main {
width: auto;
margin-left: 200px;
}
.heading {
margin: 1px;
color: #fff;
padding: 3px 10px;
cursor: pointer;
position: relative;
background-color:#000000;
}
.content {
padding: 5px 10px;
}
#submit {
width:185px;
background-color: black;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
color: #fff;
font-family:'Oswald';
font-size: 16px;
text-decoration: none;
cursor: pointer;
border:none;
}
#submit:hover {
border: none;
background:#FF9933;
box-shadow: 0px 0px 1px #777;
}
tr:nth-of-type(odd) {
background-color:#D4D4D4;
}
.container0 {
height: 100%;
width: 100%;
overflow-x: hidden;
position: relative;
padding-bottom: 30px;
background-color:black;
}
JSFiddle

in your css, set position of the sidebar to relative and set float to left, like this:
.sidebar {
width:200px;
position:relative;
top:0px;
left:0px;
height:100%;
background-color:#54524F;
float:left
}
the updated version of your jsfiddle to show you that it works :) http://jsfiddle.net/BrJDE/3/
because you dont want to have the scrollbar at the side of the page, i made some more examples for you. tell me if they are what you want, if its not, i would love to help you again.
both of these examples use 2 additional divs compared to the content you provided. these will make that you can position the scrollbar inside those div's instead of at the side of the browser. if you need me to explain the changes i made, just tell me.
scrollbar inside the page:
http://jsfiddle.net/BrJDE/6/
scrollbar inside the page at the left side of the scrolling div:
http://jsfiddle.net/BrJDE/5/

Related

PHP Loading login files into a div without reloading url

How would I be able to load all my login/profile.php files into one specific div without affecting or reloading the rest of my website? I have thought of using $_GET variables to keep the parent url the same and I have used this same tactic for my navigation menu where all my pages load in my #back_drop div.
Below I put together a very basic version of what my site looks like and as you can see the #side_panel is where I would like all my login/profile files to load into while the nav, content, and footer is unaffected by what the #side_panel does. I want to be able to login, logout, get errors, reset password, etc inside this div without it reloading the main portion of my site.
I have an index.php file which is my main index with includes for my header, aside, content, and footer and then I have an entire folder for my php files relating to my login form and other files that will load into my main content page. I didn't want to separate each include so I have them below with comments before each include noting that they are separate so you can see what I am working with.
I am currently loading my login files using an iframe because it is the simplest way to get what I am looking for but have found it very irritating at times especially when I logout and pages requiring to be logged in are still present unless the page is refreshed which seems to be a major security issue.
I have tried to use an include function into my #side_panel but if I attempt to login in, it either won't connect or will end up logging in through the parent url depending on how I edit my login.php file. I am thinking of using $_GET variables but am not sure if that would be a security issue if the variables are in the url but cannot think of any other way
index.php <-- My main index page
<?php
$page = $_GET['page'];
if (!$page) {
$page = 'Home';
}
include('includes/header.php');
echo "<div id='back_drop'><div id='content'>";
include('php/'.strtolower($page).'.php');
echo "</div></div>";
include('includes/footer.php');
?>
aside.php <-- where my login/profile files are included from
<iframe src="php/index.php" height="500px" width="100%" style="position: relative; border:none;"></iframe>
$(document).ready(function(){
$("#show_login").click(function(){
$("#side_panel").toggle("slide");
$("#side_panel").toggleClass("slide");
$(this).find('img').toggle();
if ($("#side_panel").hasClass("slide")) {
$("#back_drop").animate({'padding-left': '0'}, 300);
} else {
$("#back_drop").animate({'padding-left': '230px'}, 300);
}
});
});
* {
margin: 0;
padding: 0;
}
a {
outline: 0;
}
body {
width: 100%;
-webkit-box-pack: center;
background-color: #CCC;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
header, nav, section, aside, footer, article {
display: block;
}
#big_wrapper {
text-align: left;
width: 100%;
display: -webkit-box;
display: -moz-box;
-webkit-box-orient: vertical;
-webkit-box-flex: 1;
}
#top_header {
position: fixed;
width: 100%;
text-align: left;
padding-top: 4px;
padding-bottom: 2px;
padding-left: 4px;
border-bottom: 2px solid #262626;
border-radius: 3px 3px 0 0;
background-color: #404040;
box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.2), 2px 0 2px 2px rgba(0, 0, 0, 0.19);
z-index: 9999;
}
#back_drop {
background-color: #CCC;
padding-top: 10px;
padding-left: 230px;
max-width: 100%;
}
#content {
border: 5px solid red;
height: 500px;
}
#show_login {
float: left;
width: 24px;
padding-top: 12px;
padding-left: 5px;
height: auto;
cursor: pointer;
-webkit-user-drag: none;
-webkit-touch-callout: none;
-webkit-user-select: none;
}
#show_login:active {
width: 23px;
padding-top: 13px;
padding-right: 1px;
}
#side_panel {
position: fixed;
background-color: #a19b9b;
color: #000;
margin-top: 54.491px;
width: 230px;
height: 100%;
word-wrap: break-word;
z-index: 9999;
transform: translateX(0);
}
.slide {
transform: translateX(0);
}
#main_section {
clear: right;
text-align: center;
margin-right: auto;
}
#bottom_footer {
clear: both;
text-align: center;
padding: 20px;
background-color: #404040;
}
<!-- header.php -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<head>
</head>
<body>
<div id='big_wrapper'>
<header id='top_header'>
<nav id="navigation">
<div id="show_login">
<button>Show</button>
</div>
<div id="main_menu">
<!--Navigation header menu
<?php
$sections = array('Home','nav1','nav2','nav3','nav4','nav5');
foreach($sections as $row) {
echo "<li id='menu_list'><a href='index.php?page=$row'&login='$login'";
if ($row==$page) {
echo "class='active'";
}
echo ">$row</a>";
}
?>-->
</div>
</nav>
</header>
</div>
<div id='side_panel'>
<div id='login_contain'>
<!-- aside.php -->
#side_panel<br>
Where my login/profile pages load in
</div>
</div
<!-- This is what is actually in my code. Commented to show in snippet
<?php
echo "<div id='side_panel'><div id='login_contain'>";
include('includes/aside.php');
echo "</div></div>";
?>
-->
<div id='back_drop'>
<div id='content'>
#back_drop<br>
All my navigation links load only in this div by using href='index.php?page=(($_GET['page']))' and if I could do the same thing maybe for my #side_panel to include all my login/profile pages
</div>
</div>
<!--footer.php -->
<div class="footer_nav">
<!--Navigation footer menu
<?php
$sections = array('Home','nav1','nav2','nav3','nav4','nav5');
foreach($sections as $row) {
echo "<li><a href='index.php?page=$row'>$row</a></li>\n";
}
?>
-->
</div>
<footer id='bottom_footer'>
</footer>
</body>
</html>
Couple things here:
You will want to use AJAX for this, an iFrame is not suitable for your needs
Not sure how much of your dynamic page system is represented in your sample script but you should check on your page call on the $_GET, that method can be dangerous if someone tests your $_GET and includes a page that shouldn't.
/index.php
<?php
# Create an allow array (or have these in a database)
$public = array(
'home',
'about'
'contact'
);
# Check that it's not empty. If not empty, make sure it's allowed. Use home as default
$page = (!empty($_GET['page']) && in_array(strtolower($_GET['page']), $public))? $_GET['page'] : 'home';
# Include normally
include('includes/header.php') ?>
<div id='back_drop'>
<ul>
<li>Home</li>
<li>Contact</li>
<li>About</li>
</ul>
<div id='content'>
<?php include('php/'.$page.'.php') ?>
</div>
</div>
<!-- add jquery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(function(){
// On clicking the menu link
$('li > a').on('click',function(e){
// Stop the link from reloading page
e.preventDefault();
// Create ajax
$.ajax({
// Send request as GET
'type': 'get',
// Send to the index page
'url': '/index.php',
// equivalent of ?page={pagename}
'data': {
'page': $(this).attr('href')
},
// When request comes back, find the content and place just the content
// into this page's content
success: function(response) {
// "response" is what is coming back from the ajax all
// Find the content from the returned html
var getContent = $(response).find('#content').html();
// Place it into this page's content id
$('#content').html(getContent);
}
});
});
});
</script>
<?php include('includes/footer.php') ?>

HTML elements are contained to each other

I have a problem with some HTML elements. I have an image and a title in a <header> tag - they should both move independently to each other, however when I move the img element down 40px with the margin-top attribute - the title seems to move down 40px with it. So I add margin-top: -20px; to move it back up and it seems to stay put.
Here's my code:
The header file:
<div class="page">
<header>
<div class="titlesec">
<img class="circular" src="themes/default/image.jpg" />
<a class="logo" href="<?php echo base_url(); ?>">
<?php echo site_name(); ?>
</a>
</div>
<div class="split"></div>
</header>
The footer file:
<footer>
<p>© Copyright <?php date("Y"); ?> Duncan Hill</p>
</footer>
</div>
</body>
</html>
and my css:
.page {
width: 80%;
margin-left: 10%;
margin-right: 10%;
}
.logo {
font-family: 'Helvetica Neue';
font-weight: 100;
font-size: 56px;
text-decoration: none;
color: #555555;
margin-top: -20px;
}
.split {
height: 1px;
background-color: #CCCCCC;
}
.circular {
margin-top: 40px;
width: 80px;
height: 80px;
border-radius: 150px;
-webkit-border-radius: 150px;
-moz-border-radius: 150px;
}
.titlesec {
height: 150px;
}
Any help is appreciated immensely!
img and a are inline tags. Which means they are in the same line. Adding margin-top manipulates this line, and affects therefore both of them.
Depending on what you want to do, you could solve this with surounding both elements with their own div. Then you can style the divs independently. Maybe a float on those divs comes in handy, too.
Close your "page" DIV. It seems that your not properly closing your html tags.

How to center my page content when browser window is in full screen, and extend my footer across the entire page?

Please take a look at this site
Mess around with the browser window size for a little bit (I'm on Chrome and have not tried it with other browsers) and you will notice that my website takes up the entire page when the browser window is taking up only half of the monitor, but when the browser is in full screen mode, the content of the website stays to the left side of the webpage and the white margins get bigger. Also, my footer doesn't take up the entire page.
I don't want the site design to change, I just want all my site content to be shifted to the middle of the page when in full screen mode. I also want my footer rather then to be just sitting at the bottom of page only taking up part of it, extending across the entire page
HTML Code
<html !DOCTYPE>
<head>
<title>Mathew Crogan's Website</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div>
<form action="form.php" method="POST" id="form">
<br>
<br>
<br>Name:
<br>
<input name="contact_name" type="text">
<br>
<br>Email address:
<br>
<input type="text" name="contact_email">
<br>
<br>Message:
<br>
<textarea name="contact_text" rows="6" cols="30"></textarea>
<br>
<br>
<input type="Submit" value="Send">
</form>
<div style="height:60px; background-color:#000; color:#FFF; position:absolute; margin-left:0px; margin-top:200px;width:275px; text-align:center;">
<h3>Contact Me!</h3>
</div>
<div id="header">
<h1>Welcome To My Website!</h1>
</div>
<div id="firstlink"> <a id="firstlink" href="form.php">Main</a>
</div>
<div id="secondlink"> <a id="secondlink" href="me.php">Who I Am</a>
</div>
<div id="rollover"> <a id="rollover" href="project.php">Projects</a>
<a id="rollover" href="code.php">Code Used For These Pages</a>
</div>
<br>
<br>
<br>
<div id="condiv">
<p id="content">This is a website where I, Mathew Crogan, test out <i>HTML</i> or <i>PHP</i> or <i>CSS</i> Coding</p>
</div>
<div id="image">
<img id="me" src="img/1235154_462876267144148_1500701414_n.jpg">
</div>
<div id="footer">Web Designer: Mathew Crogan
<br>You are allowed to use this code. You can copy it from the "Code Used From These Pages" section. In order to use this code however, you must <b>GIVE CREDIT TO MATHEW CROGAN AND ASK FOR HIS PERMISSION USING THE "Contact Me" SECTION OF HIS MAIN PAGE</b>
</div>
</body>
</html>
Style.css:
html {
height:500px;
width:1000px;
;
}
#header {
height: 75px;
width: 600px;
margin-left:25px;
background-color: #DDDDDD;
text-align: center;
font-family: Tahoma, Geneva, sans-serif;
float:left;
}
#form {
float:left;
border: 1px solid #000000;
padding: 5px 5px 5px 5px;
margin-top: 200px;
}
#content {
color:red;
}
#condiv {
height:320px;
width:420px;
margin-left:315px;
margin-top:160px;
border: 1px solid #000;
border-radius:25px;
padding:10px 10px 10px 10px;
}
#image {
height:350px;
width:300px;
position:relative;
left:800px;
bottom:380px;
}
#me {
border:2px solid #000;
border-radius:25px;
}
#secondlink {
margin-left:190px;
}
a#rollover:link, a#rollover:visited {
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#B5B5B5;
width:120px;
text-align:center;
padding:4px;
text-decoration:none;
border:1px solid #000;
float:left;
margin-top:30px;
height:40px;
padding-top:8px;
}
a#rollover:hover, a#rollover:active {
background-color:#A7A7A7;
}
a#firstlink:link, a#firstlink:visited {
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#B5B5B5;
width:120px;
text-align:center;
height:44px;
padding-top:8px;
text-decoration:none;
border:1px solid #000;
position:absolute;
margin-top:105px;
margin-left:343px;
}
a#firstlink:hover, a#firstlink:active {
background-color:#A7A7A7;
}
a#secondlink:link, a#secondlink:visited {
display:block;
font-weight:bold;
color:#FFFFFF;
background-color:#B5B5B5;
width:120px;
text-align:center;
padding:4px;
text-decoration:none;
border:1px solid #000;
margin-top:30px;
float:left;
height:40px;
padding-top:8px;
}
a#secondlink:hover, a#secondlink:active {
background-color:#A7A7A7;
}
#footer {
display:block;
text-align:center;
border:1px solid #000;
background-color:#B5B5B5;
width:1000px;
position:absolute height:100px;
float:left;
padding:5px 20px 5px 20px;
margin-top:400px;
}
You can centre the whole body so you can have the space on both sides:
html {
height:500px;
width:1000px;
margin: 0 auto;
}
This is the most common method to center block elements in css, as explained in the link. However, I'd change it to something even more common:
html {
width: 100%:
}
body {
height:500px;
width:960px;
margin: 0 auto;
}
In this way, you can be assured that the html is the "base" for your meassures, and it's the full width of the page. Then you can work with the body. Also I set it a little smaller, to 960px, because one of the common resolutions is 1024px wide and with the scrollbars and other things it gets to just above that measure.
Lastly, the footer is a story apart that needs a huge article. And other people has already done it, it's called sticky footer, and google will provide enough information:
http://css-tricks.com/snippets/css/sticky-footer/

Buttons with mouse over and out function

Check this url please http://x2t.com/262032
You can see how does facebook button work right side of navigation menu.
This code works with this button.
CSS
div.social-wrapper {
float: right;
text-align: right;
font-size: 15px;
font-weight: bold;
margin: 11px 15px 0px 0px;
}
div.social-wrapper-text {
margin-bottom: 10px;
}
div.social-icon:first-child {
margin-left: 0px;
}
div.social-icon {
float: left;
margin-left: 11px;
opacity: 0.55;
filter: alpha(opacity=55);
cursor: pointer;
}
I need the code for two facebook buttons with mouse over and out function.
On mouse over guest will see for example white FB button and on mouse over black one.
How to do this?
<button class="class_of_button"> like us on facebook </button>
.class_of_button {
background: url('source of fb image');
}
.class_of_button:hover {
background: url('source of black fb image');
}
Here my personal solution for this:
HTML:
<div class="social-icon">
<a href="CHANGE THIS LINK TO YOUR ONE">
<img src="MOUSE_OFF.jpg"></img>
<img src="MOUSE_ON.jpg"></img>
</a>
</div>
CSS:
<style type="text/css">
div.social-icon
{
width: 600px; /* Width of IMG, TO BE CHANGED *
height: 800px; /* Height of IMG, TO BE CHANGED *
}
div.social-icon img:nth-child(2)
{
display: none;
}
div.social-icon img:first-child
{
display: block;
}
div.social-icon:hover img:nth-child(2)
{
display: block;
}
div.social-icon:hover img:first-child
{
display: none;
}
</style>
Just put the CSS into the
and the html where you would have placed your button.
And don't forget to change the mentioned values in the css and html.
And yes: You have to create the images yourself, so show yourself some Paint skillz~

Centering my css3 menu of changing widths...?

I have a css menu which has a width of 400 for non-Admins... and a width of 500 for Admins. If I set the UL width to 500, the menu centers fine and nicely for Admins. But for non-admins, whose mneu is really only 400 wide... it's off-kilter.
So I removed the width attribute from the UL to try and remove this and then it lost centering altogether; the whole menu is now stuck to the left side of the container.
Anyone have a simple idea for how to make it always centered? Site is here:
http://www.runic-paradise.com/
ul.menu{
height: 40px;
list-style: none outside none;
margin: 0 auto;
/*width: 500px;*/
}
/*li{
width:100px;
height:50px;
float:left;
color:#191919;
text-align:center;
overflow:hidden;
}*/
a.menu{
color:#FFF;
text-decoration:none;
}
p.menu{
padding-top: 10px;
padding-right: 5px;
padding-left: 5px;
}
.subtext{
padding-top: 10px;
}
ul.menu li{
width: 100px;
height: 40px;
float: left;
color: #191919;
text-align: center;
overflow: hidden;
}
/*Menu Color Classes*/
.green{
background:#6AA63B url('/img/menu/green-item-bg.jpg') top left no-repeat;
}
.yellow{
background:#FBC700 url('/img/menu/yellow-item-bg.jpg') top left no-repeat;
}
.red{
background:#D52100 url('/img/menu/red-item-bg.jpg') top left no-repeat;
}
.purple{
background:#5122B4 url('/img/menu/purple-item-bg.jpg') top left no-repeat;
}
.blue{
background:#0292C0 url('/img/menu/blue-item-bg.jpg') top left no-repeat;
}
<ul class="menu">
<li class="green">
<p class="menu">Home</p>
<p class="subtext">The front page</p>
</li>
<li class="yellow">
<p class="menu">-</p>
<p class="subtext">More info</p>
</li>
<li class="red">
<p class="menu">Forums</p>
<p class="subtext">Get in touch</p>
</li>
<li class="blue">
<p class="menu">-</p>
<p class="subtext">Send us your stuff!</p>
</li>
<?php
if ($user->data['group_id'] == 5)
{
echo ' <li class="purple">
<p class="menu">Admin</p><p class="subtext">Legal things</p>
</li>';
}
?>
</ul>
Your CSS sets the ul.menu width to 400px. If the user is admin, the php script adds another 100px wide li to ul.menu. When this happens, you have to set the ul.menu width to 500px. If you do this, the css rule margin:0px auto; will handle the centering as expected.
A simple jQuery fix would be something like this:
<script>
$(document).ready(function() {
var menu=$('ul.menu');
if(menu.find('li')>4) {
//if there are more then 4 menu items, reset menu width to 500px
menu.css('width','500px');
}
});
</script>
Use max-width:500px;for UL.Demo for these http://jsfiddle.net/dhanith/ZMB93/
Can you please try this,
In animated-menu.css (demo url: http://www.runic-paradise.com/), Change margin style as like below
ul.menu {
height: 40px;
list-style: none outside none;
margin: auto 25%;
}

Categories