how to change overflow? - php

I am doing a college project. I need to change the scrolling position from Horizontal to Vertical, But that's not working. Here I'm using PHP and HTML, CSS. Can any one fix my code please? I am new to css.
This is my current output:
My code:
<style>
div.boxx
{
background-color:#9C0;
width:150px;
height:150px;
margin-left:20px;
text-align:center;
float:left;
}
div.boxx:hover
{
background:#333;
}
div.inside1
{
width:100px;
height:100px;
margin-left:auto;
margin-right:auto;
position:relative;
margin-top:10px;
bottom:0px;
border:solid #666;
border-width:thin;
}
div.inside2
{
width:auto;
height:40px;
margin-left:auto;
margin-right:auto;
margin-top:5px;
text-align:center;
}
div.button1
{
width:15px;
height:25px;
left:85px;
float:right;
position:absolute;
top:0px;
}
table.main_table
{
margin-left:auto;
margin-right:auto;
width:auto;
}
tr.toptr
{
background:url(images/available_gallary_top.png) no-repeat;
height:38px;
}
tr.boatamtr
{
background:url(images/available_gallary_bottam.png) no-repeat;
height:7px;
}
tr.fulltr
{
background:url(images/available_gallary_bg.png) repeat-y;
}
div.gal_cantiner
{
background-color:#09C;
width:869px;
margin-left:2px;
height:152px;
overflow:auto;
}
input.delet_gal_bt
{
width:13px;
height:13px;
background:url(images/delet_gal_bt.png) no-repeat;
border:none;
}
input.delet_gal_bt:hover
{
background:url(images/delet_gal_bt_h.png) no-repeat;
}
input.remove_gal_bt
{
width:13px;
height:13px;
background:url(images/remove_gal_bt.png) no-repeat;
border:none;
}
input.remove_gal_bt:hover
{
background:url(images/remove_gal_bt_h.png) no-repeat;
}
span.gallary_date_text
{
color:#666;
font-size:9px;
line-height:15px;
}
</style>
<?php
session_start();
include "config.php";
error_reporting(0);
echo "<br>";
$crt=0;
$sql= mysql_query("SELECT * FROM new_gallary",$con);
echo "<table class='main_table' border='0' align='center'><tr class='toptr'><td> </td></tr><tr class='fulltr'><td><div class='gal_cantiner' id='gal_cantiner'>";
while($row = mysql_fetch_array($sql))
{
echo "<div class='boxx' id='boxx".$crt."'><div class='inside1'><img src='".$galimg."' width='100' height='100'><div class='button1'><input type='button' class='delet_gal_bt' onclick='deleted_gallary(".$row['id'].")'/><input type='button' class='remove_gal_bt' onclick='remove_for_gallary(".$row['id'].")'/></div></div><div class='inside2'>".$row['gallary_name']."<br><span class='gallary_date_text'>".$row['gallary_date']."</span></div></div>";
$crt++;
}
echo "</div></td></tr><tr class='boatamtr'><td></td></tr></table>";
?>

I finally found the answer. I add a new style line into the tr that will inside of the loop like this:
$l=$l+100;
echo"
<div class='boxx' id='boxx".$crt."' style="margin-left:".$l."px;margin-top:-160px;">
<div class='inside1'>
<img src='".$galimg."' width='100' height='100'>
<div class='button1'>
<input type='button' class='delet_gal_bt' onclick='deleted_gallary(".$row['id'].")'/>
<input type='button' class='remove_gal_bt' onclick='remove_for_gallary(".$row['id'].")'/>
</div>
</div>
<div class='inside2'>".$row['gallary_name'].">
<br>
<span class='gallary_date_text'>".$row['gallary_date']."</span>
</div>
</div>
";
style="margin-left:".$l."px; margin-top:-160px;
THe Final Output:Image

Try this.
overflow: auto;
overflow-x: hidden;
And please cut short the code : sscce

#user1126301 your code doesn't seems to have any scroll bars. It just uses the existing images.
You should add this in your css:
overflow-y: scroll; overflow-x: hidden; padding-right: 5px;
visibility: visible; border: thin solid white; background-color:#336699;
scrollbar-face-color: #336699; scrollbar-3dlight-color: #336699;
scrollbar-base-color: #336699; scrollbar-track-color: #336699;
scrollbar-darkshadow-color: #000; scrollbar-arrow-color: #000;
scrollbar-shadow-color: #fff; scrollbar-highlight-color: #fff;

Related

PHP Customizing div to place next to each other

I have a problem. I created this code that shows products from my database like products:
<?php
include("connect.php");
session_start();
$status="";
if (isset($_POST['id']) && $_POST['id']!="")
{
$Id = $_POST['id'];
$result = mysqli_query($conn,"SELECT * FROM Producten WHERE `Id`='$Id'");
$row = mysqli_fetch_assoc($result);
$naam = $row['Naam'];
$id = $row['Id'];
$prijs = $row['Prijs'];
$foto = $row['Foto'];
$winkelwagen_array = array(
$id=>array(
'id'=>$id,
'naam'=>$naam,
'prijs'=>$prijs,
'hoeveelheid'=>1,
'foto'=>$foto)
);
if(empty($_SESSION["winkelwagen"]))
{
$_SESSION["winkelwagen"] = $winkelwagen_array;
$status = "<div class='box'>Product toegevoegd aan winkelwagen!</div>";
}
else
{
$_SESSION["winkelwagen"] = array_merge($_SESSION["winkelwagen"],$winkelwagen_array);
$status = "<div class='box'>Product toegevoegd aan winkelwagen!</div>";
}
}
?>
<html>
<head>
<link rel='stylesheet' href='css/style.css' type='text/css' media='all' />
</head>
<body>
<div style="width:700px; margin:50 auto;">
<?php
if(!empty($_SESSION["winkelwagen"]))
{
$winkelwagen_hoeveelheid = count(array_keys($_SESSION["winkelwagen"]));
?>
<div class="winkelwagen_div">
<img src="media/winkelwagen_logo.png" /> Winkelwagen<span><?php echo $winkelwagen_hoeveelheid; ?></span>
</div>
<?php
}
$result = mysqli_query($conn,"SELECT * FROM Producten");
while($row = mysqli_fetch_assoc($result))
{
echo "<div class='product_vak'>
<form method='post' actie=''>
<input type='hidden' name='id' value=".$row['Id']." />
<div class='foto'><img src='".$row['Foto']."' /></div>
<div class='naam'>".$row['Naam']."</div>
<div class='prijs'>€".$row['Prijs']."</div>
<button type='submit' class='koop'>Koop nu</button>
</form>
</div>";
}
mysqli_close($conn);
?>
<div style="clear:both;"></div>
<div class="melding_box" style="margin:10px 0px;">
<?php echo $status; ?>
</div>
</div>
</body>
</html>
with this css:
.product_vak {
float:left;
padding: 10px;
text-align: center;
}
.product_vak:hover {
box-shadow: 0 0 0 2px #e5e5e5;
cursor:pointer;
}
.product_vak .naam {
font-weight:bold;
}
.product_vak .koop {
text-transform: uppercase;
background: #F68B1E;
border: 1px solid #F68B1E;
cursor: pointer;
color: #fff;
padding: 8px 40px;
margin-top: 10px;
}
.product_vak .koop:hover {
background: #f17e0a;
border-color: #f17e0a;
}
.melding_box .box{
margin: 10px 0px;
border: 1px solid #2b772e;
text-align: center;
font-weight: bold;
color: #2b772e;
}
.table td {
border-bottom: #F0F0F0 1px solid;
padding: 10px;
}
.winkelwagen_div {
float:right;
font-weight:bold;
position:relative;
}
.winkelwagen_div a {
color:#000;
}
.winkelwagen_div span {
font-size: 12px;
line-height: 14px;
background: #F68B1E;
padding: 2px;
border: 2px solid #fff;
border-radius: 50%;
position: absolute;
top: -1px;
left: 13px;
color: #fff;
width: 14px;
height: 13px;
text-align: center;
}
.winkelwagen .verwijderen {
background: none;
border: none;
color: #0067ab;
cursor: pointer;
padding: 0px;
}
.winkelwagen .verwijderen:hover {
text-decoration:underline;
}
But when I load the page I see 2 products above each other in a very very large size. Now how can I get them to load next to each other and in a smaller size, because now they are filling the whole screen per product!
I already tried giving product_vak a width, but the image doesn't size with that!
How can I fix this?
try like this
.product_vak {
float:left;
padding: 10px;
text-align: center;
width:40%;

How to get a horizontal bar that fills out the remaining space?

I want it like this:
So that the #header-nav is a horizontal bar which has the links(#nav-bar) and that the #bar fills out the remaining space but doesn't wrap to the next row or go behind the links. So it would be like one of the links but extends as far as the #header-nav allows.
The HTML:
<div id="header-nav">
<div id="nav-bar">
<ul>
<li>Home</li>
<li>Page1</li>
<li>Page2</li>
<li>Page3</li>
<li>Page4</li>
</ul>
</div>
<div id="bar"></div>
</div>
The CSS:
#header-nav ul
{
padding-left:0px;
margin: 0;
padding-top:10px;
padding-bottom:10px;
list-style-type:none;
text-align: left;
float:center;
margin-top:0px;
}
#header-nav ul li
{
margin-left:1px;
display: inline;
}
#header-nav ul li a
{
text-decoration:none;
padding: .2em .4em;
color: black;
border:1px solid lightgrey;
background-color:lightgrey;
}
Look up display: flex, flex: auto and flex: none. Combined with width: 100% for the container, that should give you what you are looking for.
My brother found out a solution.
Heres the link to jsfiddle
The CSS:
<body>
<div id="header-nav">
<div id="cell1">
<div id="buttons">
<ul>
<li>Home</li>
<li>Page1</li>
<li>Page2</li>
<li>Page3</li>
<li>Page4</li>
</ul>
</div>
</div>
<div id="cell2">
<div id="bar">
</div>
</div>
</div>
</body>
The HTML:
#buttons ul li a {
text-decoration:none;
padding: 5px 10px 5px 10px;
color: black;
border:1px solid lightgrey;
background-color:lightgrey;
}
#buttons ul {
padding-left:0px;
margin: 0;
padding-top:10px;
padding-bottom:10px;
list-style-type:none;
text-align: left;
}
#buttons ul li {
margin-left:1px;
display: inline;
}
#header-nav {
display:table;
width:100%;
}
#cell1 {
display:table-cell;
white-space: nowrap;
vertical-align:top;
}
#buttons {
float:left;
}
#cell2 {
display:table-cell;
width:100%;
padding: 4px 3px 5px 4px;
vertical-align:top;
}
#bar {
float:left;
width:100%;
background-color:black;
height:29px;
background-color:lightgrey;
}
Can you show me your css? Check this out :
http://jsfiddle.net/1ds7t19p/1/
#header-nav {
width:800px;
background:#ccc;
height:50px;
}
#nav-bar ul {
width:465px;
float: left;
padding: 0;
}
#nav-bar ul li{
display: inline-block;
}
#nav-bar ul li a{
padding:10px 25px;
background:#999;
height:50px;
}
#bar {
float: right;
height:50px;
}

sidebar height is upto something is written

I am not able to make the sidebar all the way touch to the footer earlier it was going to the bottom but i made few changes for hours and suddenly when i checked it sidebar color only shows till it displays some links.
css:
*{margin:0; padding:0;}
html{ width:1024px; height:100%; margin: 0 auto; }
body{ width:100%;height:100%;
margin:0; padding:0; border:0;
font-family:Verdana,Helvetica,Arial,sans-serif;
font-size: 13px; line-height: 16px;
background: #FFFFFF; text-align: center;
display: table;
}
#main { height:auto; min-height:100%; }
/* header */
#header{
background-color:#c42000;
height:75px; margin:0; padding:0;
border:0 solid;
}
#header h1{
line-height:15px; padding:1em;
}
#header h1 a{
color:#FFFFFF;
text-decoration:none;
}
#header h1 a:hover {
color:#cda154;
}
/* Navigation */
#navigation {
color:#d3d3d3;
height:45px;
background:#262525;
float:top;
}
#navigation .subjects {
background: #262525;
float: left;
font-weight:bold;
margin: 0; padding: 0;
border-bottom: none;
}
#navigation .subjects li a, #navigation .subjects li {
float: left;
}
#navigation .subjects li {
list-style: none;
position: relative;
}
#navigation .subjects li a {
padding: 1em 2em;
text-decoration: none;
color: white;
background: #292929;
border-right: 1px solid #3c3c3c;
border-left: 1px solid #292929;
border-bottom: 1px solid #232323;
border-top: 1px solid #545454;
}
#navigation .subjects li a:hover {
background: #302f2f; color:#16a9e0;
}
/* Submenu */
#navigation .subjects li ul {
display: none;
pos
ition: absolute;
left: 0;
top: 100%;
padding: 0; margin: 0;
}
#navigation .subjects li:hover > ul {
display: block;
}
#navigation .subjects li ul li, #navigation.subjects li ul li a {
float: none;
}
#navigation .subjects li ul li {
_display: inline; /* for IE6 */
}
#navigation .subjects li ul li a {
width: 150px;
display: block;
}
/* Sidebar */
#sidebar {
float:right;
width: 150px; height: 100%;
margin: 0; padding: 0 2em;
color: #D4E6F4; background: #16aae2;
}
#sidebar a { color: #D4E6F4; text-decoration: none; }
#sidebar a:hover { color: #FFFFFF; }
/* footer */
#footer {
clear: both; position: relative;
height: 2em; margin: 0; padding: 1em; margin-top: -3em; z-index:10;
text-align: center;
background: #000000; color: #D4E6F4;
}
/* page */
#page {
display:table-cell;
float:left;
line-height: 30px;
text-align: left;
padding: 2em;
}
h2 { color:#c42000; }
div.message,div.error {
color: #8D0D19; font-weight:bold;
margin: 1em 0; padding: 1em;
}
div.images {
width:92;height:92; float:left; padding: 0 10px 0; display:block;
}
div.images a{ text-decoration:none;}
php:
<?php require_once("../includes/session.php"); ?>
<?php require_once("../includes/db_connection.php"); ?>
<?php require_once("../includes/functions.php"); ?>
<?php $layout_context = "admin"; ?>
<?php include("../includes/layouts/header.php"); ?>
<?php find_selected_page(); ?>
<div id="main">
<div id="navigation">
<?php echo navigation($current_subject, $current_page); ?>
</div>
<div id="page">
<?php echo message(); ?>
<?php if(isset($current_subject)) {?>
<h2>Manage Subject</h2>
Menu name: <?php echo htmlentities($current_subject["menu_name"]); ?><br />
Position: <?php echo $current_subject["position"]; ?><br />
Visible: <?php echo $current_subject["visible"] == 1 ? 'yes' : 'no'; ?><br /><br />
<a href="edit_subject.php?subject=<?php echo urlencode($current_subject["id"]); ?>
">Edit Subject</a>
<div style="margin-top: 2em; border-top: 1px solid #000000;">
<h2>Pages in this subject:</h2>
<?php
$subject_pages = find_pages_for_subject($current_subject["id"]);
while($page = mysqli_fetch_assoc($subject_pages)) {
$safe_page_id = urlencode($page["id"]);
echo "<a href=\"manage_content.php?page={$safe_page_id}\">";
echo htmlentities($page["menu_name"]);
echo "</a><br />";
}
?>
<br />
+ Add a new page to this subject
</div>
<?php }elseif($current_page) {?>
<h2>Manage Page</h2>
<?php ?>
Page Name: <?php echo htmlentities($current_page["menu_name"]); ?><br />
Position: <?php echo $current_page["position"]; ?><br />
Visible: <?php echo $current_page["visible"] == 1 ? 'yes' : 'no'; ?><br />
<br />
<br />
Edit Page<br /><br />
<?php echo display_image_by_id(); ?>
<?php }else { ?>
Please Select a Subject or Page.
<?php } ?>
</div>
<div id="sidebar">
« Main Menu
<br />
<br />
+ Add a subject
</div>
</div>
<?php include("../includes/layouts/footer.php"); ?>

Proplem in div right align?

i have php program that contain div main_wrapper that div have two sub div resultwrapper and adv_right. I want adv_right div exactly right side of the resultwrapper div.When i'm use float mean that div present outside of the main_wrapper div.
<style>
.resultwrapper{width:990px; margin: 10px auto 10px auto; clear:both; }
.resultitem{ float: left;
height: 170px;
margin-bottom: 0px;
margin-left: 10px;
min-height: 130px;
width:218px;}
.resultleftitem{padding-left:0;margin-left:0px;}
.resultitem img{border:dotted 1px #666; padding:6px;}
.resultitem img:hover{border:solid 1px #F60;}
.resultitem h4{font-size:12px; font-weight:bold; color:#249ce9; margin-top:5px; }
.resultitem a{color:#249ce9;}
.resultitem .caption{color:#9c9c9c; font-size:12px; display:block; margin-top:6px; text-align:justify;}
</style>
<div class="main_warpper">
<div class="resultwrapper">
<?php
while($row = mysql_fetch_array($rs)) {
$id=$row['id'];
$type=$row['type'];
$location=$row['location'];
if(file_exists("properties//". $imageloc ."//thumb.jpg") )
{
$thumb_img="properties/". $imageloc ."/thumb.jpg";
} else {
$thumb_img="images/default.jpg";
}
if($cnt==0 || $cnt ==4 ) $newResult=true; else $newResult=false;
?>
<div id="parent" >
<div class="resultitem <?php if($newResult) echo ' resultleftitem'; ?>" id="resultitem"> <a href="viewpropdetails.php?id=<?php echo $id;?>" target="_blank">
<img id="parent" src="<?php echo $thumb_img; ?>" alt="<?php $new=strtolower($heading); echo ucwords($new); ?>" title="<?php $new=strtolower($heading); echo ucwords($new); ?>" width="100" height="100" /></a>
<div class="itemdetails">
<h4 id="linkheading"><?php echo $type ." # ".$location; ?></h4>
<span class="box"><?php echo cropStr($desc,$MAX_DESC); ?></span>
</div>
</div>
</div>
<?php
$cnt++; } ?>
</div>
<div class="adv_right" style=" clear:both; width:15%; float:right;height:300px; background-color:#999999;">
</div>
</div>
Please try it,
Remove clear:both; from both div and set width what u want ,,
Please try this code you want like this ??
<style>
.resultwrapper {
margin: 10px auto 10px auto;
}
.resultitem {
float: left;
height: 170px;
margin-bottom: 0px;
margin-left: 10px;
min-height: 130px;
width:218px;
}
.resultleftitem {
padding-left:0;
margin-left:0px;
}
.resultitem img {
border:dotted 1px #666;
padding:6px;
}
.resultitem img:hover {
border:solid 1px #F60;
}
.resultitem h4 {
font-size:12px;
font-weight:bold;
color:#249ce9;
margin-top:5px;
}
.resultitem a {
color:#249ce9;
}
.resultitem .caption {
color:#9c9c9c;
font-size:12px;
display:block;
margin-top:6px;
text-align:justify;
}
</style>
<div class="main_warpper">
<div class="resultwrapper">
<?php
while($row = mysql_fetch_array($rs)) {
$id=$row['id'];
$type=$row['type'];
$location=$row['location'];
if(file_exists("properties//". $imageloc ."//thumb.jpg") )
{
$thumb_img="properties/". $imageloc ."/thumb.jpg";
} else {
$thumb_img="images/default.jpg";
}
if($cnt==0 || $cnt ==4 ) $newResult=true; else $newResult=false;
?>
<div id="parent" >
<div class="resultitem <?php if($newResult) echo ' resultleftitem'; ?>" id="resultitem"> <img id="parent" src="<?php echo $thumb_img; ?>" alt="<?php $new=strtolower($heading); echo ucwords($new); ?>" title="<?php $new=strtolower($heading); echo ucwords($new); ?>" width="100" height="100" />
<div class="itemdetails">
<h4 id="linkheading"><?php echo $type ." # ".$location; ?></h4>
<span class="box"><?php echo cropStr($desc,$MAX_DESC); ?></span> </div>
</div>
</div>
<?php
$cnt++; } ?>
</div>
<div class="adv_right" style="width:15%; float:right;height:300px; background-color:#999999;">23123 </div>
</div>
add float:left here
<div class="resultwrapper" style="float:left;">
and rempove clear:both and add float:left
<div class="adv_right" style=" clear:both; width:15%; float:left;height:300px;
background-color:#999999;">
see demo here ....http://jsfiddle.net/6e4xN/1/
when you going to use this code it will not work with more than 7-8 elements, to work when you have more elements then use below stylesheet.
<style>
.resultwrapper {
margin: 10px auto 10px auto;
width:80%;
float:left;
}
.resultitem {
float: left;
height: 170px;
margin-bottom: 0px;
margin-left: 10px;
min-height: 130px;
width:150px;
}
.resultleftitem {
padding-left:0;
margin-left:0px;
}
.resultitem img {
border:dotted 1px #666;
padding:6px;
}
.resultitem img:hover {
border:solid 1px #F60;
}
.resultitem h4 {
font-size:12px;
font-weight:bold;
color:#249ce9;
margin-top:5px;
}
.resultitem a {
color:#249ce9;
}
.resultitem .caption {
color:#9c9c9c;
font-size:12px;
display:block;
margin-top:6px;
text-align:justify;
}
</style>
Let me know if it works for you or not.
I guess there is some problem in the code. You CANNOT use the same ID for multiple elements in a page. Secondly when you are using percent width for the adv_right div, why don't you use the same for resultwrapper div with both the resultwrapper & adv_right divs floated left and no clear:both in the css. I feel this should solve your problem.

Comment System CSS text gets out of box

I have recently coded a simple comment system using PHP.
http://runescapepvp.net/jony/index.php
As you see in the following link I posted, if the comment is long, it will get out of the box.
Im not to sure why it happens when I've set max width for text.
Im using this to call the boxes
function showComments() {
$query = mysql_query("SELECT * FROM `comments` ORDER BY `comment_id` DESC LIMIT 5") or die (mysql_error());
$allcomments = mysql_query("SELECT * FROM `comments` ORDER BY `comment_id`") or die (mysql_error());
if (mysql_num_rows($query) == 0) {
echo '<br /><br />';
handleAlerts("noComments");
} else {
while ($row = mysql_fetch_assoc($query)) {
echo "
<br />
<br />
<div class='comments'>
<div class='title'><span class='author'>Posted by: ".$row['comment_guest']."</span><span class='date'>At ".$row['comment_time'].", ".$row['comment_date']."</span></div>
<div class='comment'>
<span class='message'>
".$row['comment']."
</span>
<br />
<a href='index.php?delete=comment&id=".$row['comment_id']."'><div class='button_delete'>Delete</div></a>
</div>
</div>
";
}
}
echo '<br /><br /><br />';
}
CSS:
.title {
background-image: url("../img/header.png"); background-repeat: repeat-x;
width: 100%;
height: 56px;
border: solid 1px #a8a8a8;
line-height: 56px;
font-size: 17px;
color: grey;
text-align: left;
display: block;
}
.comments {
position: relative;
top: 50px;
}
.comment {
width: 640px;
height: auto;
display: block;
min-height: 100px;
background-color: #e6e6e6;
border-left: solid 1px #a8a8a8;
border-right: solid 1px #a8a8a8;
border-bottom: solid 1px #a8a8a8;
}
.message {
width: 600px;
display: block;
margin-left: auto;
margin-right: auto;
padding-top: 10px;
}
Why is it happening?
I am not really sure if the error is related to PHP.
Thanks a lot!
You can try adding this CSS to your .comment class:
word-break: break-all;
Or
overflow: auto;
You can solve this in css:
To hide what is not part of the box:
.comment {
overflow: hidden;
}
To use the new css3 property to break the long word:
.comment {
word-break: break-all;
}

Categories