Proplem in div right align? - php

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.

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%;

CSS hover effect on single results from mysql fetch

I looked up online and didn't find the answer. English is my second language, so I think I'm not looking with the good words. I have a search engine on my website and I want to have a "bump" effect when I hover a result. The problem is, when I hover a result, it affects all of them simultaneously.
HTML-PHP
while ($row = mysql_fetch_assoc($getquery)) {
$id = $row['ID'];
$input1 = $row['name'];
echo '<div class="foo">';
echo '<div class="fooimage">';
echo "<a href='details.php?id=$id'> <img alt='Image goes here' src='portal_user/submit_form/" . $row["Photos"] . "' width=190px height=140px></a>";
echo '</div>';
echo '<div class="footext">';
echo "<div class='input1'>";
echo "<a href='details.php?id=$id'>$input1</a>";
echo "</div>";
echo "</div>";
echo "</div>";
}
CSS
.foo {
position: relative;
height: 205px;
width: 200px;
display: inline-block;
background-color: #ececec;
margin-left: 20px;
margin-bottom: 10px;
margin-top: 0px;
box-shadow: 5px 5px 3px #888888;
transition: .7s
}
.foo:hover {
margin-bottom: 10px;
margin-top: -5px;
}
I want to have the bump effect on the foo div. The results need to stay inline-block to have them in rows and not one on top of the other.
You'll need a little jQuery help here I think. I also changed the CSS a little bit, but adjust as necessary:
$( ".foo" ).hover(
function() {
$(this ).addClass('hover');
}, function() {
$( this ).removeClass('hover');
}
);
.foo {
position: relative;
top: 0;
height: 205px;
width: 200px;
display: inline-block;
background-color: #ececec;
margin-left: 20px;
margin-bottom: 10px;
margin-top: 0px;
box-shadow: 5px 5px 3px #888888;
transition: .7s
}
.foo.hover {
position: relative;
top: -10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="foo">
<div class="fooimage">
<a href='details.php?id=$id'>
<img alt='Image goes here' src='http://placehold.it/190x140' width=190px height=140px>
</a>
</div>
<div class="footext">
<div class='input1'>
<a href='#'>$input1</a>
</div>
</div>
</div>
<div class="foo">
<div class="fooimage">
<a href='details.php?id=$id'>
<img alt='Image goes here' src='http://placehold.it/190x140' width=190px height=140px>
</a>
</div>
<div class="footext">
<div class='input1'>
<a href='#'>$input1</a>
</div>
</div>
</div>
<div class="foo">
<div class="fooimage">
<a href='details.php?id=$id'>
<img alt='Image goes here' src='http://placehold.it/190x140' width=190px height=140px>
</a>
</div>
<div class="footext">
<div class='input1'>
<a href='#'>$input1</a>
</div>
</div>
</div>

Positioning issues with CSS when pages have elements missing

There is a specific section of my website which had broken look due to bad CSS & PHP code, which I decided to fix today. With good luck fixed a lot of it(and learned CSS along the way).
The pages I fixed have dynamic content on them - Badges like we have here on stackoverflow. Depending on user level, some people may not have any badges.
The problem is, while pages that have badges look alright, the ones which don't look entirely broken, and the rest of the content on pages shifts when there are no badges.
Any thoughts on how should I go about fixing it?
CSS:
.ms-sellerprofile {
width: 100%;
align:center;
}
.ms-sellerprofile .seller-data {
width: 100%;
display: inline-block;
align:center;
}
.ms-sellerprofile .seller-data > div {
display: inline;
float: left;
}
.ms-sellerprofile .seller-data .avatar-box-img {
float:left;
width:250px;
display: inline-block;
margin-top:10px;
margin-bottom:10px;
}
.ms-sellerprofile .seller-data div.avatar-box {
margin-left: 10px;
width:250px;
text-align: left;
font-family: Helvetica, Arial, sans-serif;
font-size: 22px;
display: inline-block;
margin-top:10px;
margin-bottom:10px;
}
.ms-sellerprofile .seller-data .info-box {
margin-top: 10px;
margin-left: 290px;
text-align: right;
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
}
.ms-sellerprofile .seller-data div.ms-badges {
border: 0;
margin-left: -240px;
margin-top: 40px;
}
.ms-sellerprofile .seller-data div.info-box p {
margin: 5px 0;
}
.ms-sellerprofile .seller-data div.info-box a {
color: #38B0E3;
text-decoration: underline;
}
.ms-sellerprofile .seller-description {
clear: both;
margin: 40px 0;
}
PHP:
<div class="ms-sellerprofile">
<div class="seller-data">
<div class="avatar-box-img"><img src="<?php echo $seller['thumb']; ?>" />
</div>
<div class="avatar-box"><?php echo $ms_catalog_seller_products; ?>
</div>
<div class="ms-badges"><?php foreach($seller['badges'] as $badge) { ?>
<img src="<?php echo $badge['image']; ?>" title="<?php echo $badge['description']; ?>" /></div>
<?php } ?>
<div class="info-box">
<?php if ($seller['country']) { ?>
<p><b><?php echo $ms_catalog_seller_profile_country; ?></b> <?php echo $seller['country']; ?></p>
<?php } ?>
<?php if ($seller['company']) { ?>
<p><b><?php echo $ms_catalog_seller_profile_company; ?></b> <?php echo $seller['company']; ?></p>
<?php } ?>
<?php if ($seller['website']) { ?>
<p><b><?php echo $ms_catalog_seller_profile_website; ?></b> <?php echo $seller['website']; ?></p>
<?php } ?>
<!-- <p><b><?php echo $ms_catalog_seller_profile_totalsales; ?></b> <?php echo $seller['total_sales']; ?></p> -->
<p><b><?php echo $ms_catalog_seller_profile_totalproducts; ?></b> <?php echo $seller['total_products']; ?></p>
</div>
</div>
</div>
You should handle the exception cases explicitly.
if($var==NULL){
//html without using $var
}
else{
//html with use of $var
}

Menu doesn't make a block

This menu is made in html and php. I have a menu in css. Whenever I mouse over on menu item it doesn't make a link on mouseover, and whenever I click on text it make a link.
<div class="panel panel-default">
<div class="panel-heading">
<?php if($menurow['hassubmenu'] != NULL)
{?>
<a data-toggle="collapse" data-parent="#accordian" href="#<?php echo $menurow['mainmenuid']; ?>" title="<?php echo $menurow['title']; ?>"><span class="badge pull-right"><i class="fa fa-plus"></i></span><?php echo $menurow['title']; ?></a>
<?php }else{?>
<h4 class="panel-title"><?php echo $menurow['title']; ?></h4>
<?php } ?>
</div>
<?php if($menurow['hassubmenu'] != NULL){?>
<div id="<?php echo $menurow['mainmenuid']; ?>" class="panel-collapse collapse">
<div class="panel-body">
<ul>
<?php
$menuquery2 = mysql_query("select title,itemid,catid from submenu where mainmenuid=".$menurow['mainmenuid']." order by sort asc");
while($menurow2 = mysql_fetch_assoc($menuquery2))
{
if($menurow2['itemid'] != NULL)
$menulink2 = "showitem.php?id=".$menurow2['itemid'];
elseif($menurow2['catid'] != NULL)
$menulink2 = "category.php?id=".$menurow2['catid'];
else
$menulink2 = "#";
?>
<li><?php echo $menurow2['title']; ?></li>
<?php }?>
</ul>
</div>
</div>
<?php }?>
</div>
CSS Code
/* New menu */
.category-products .panel {
background-color: #FFFFFF;
border: 0px;
border-radius: 0px;
box-shadow:none;
margin-bottom: 0px;
}
.category-products .panel-default .panel-heading {
background-color: #CCCCCC;
border: 1px solid;
color: #FFFFFF;
padding: 5px 20px;
cursor:pointer;
height:40px;
}
.category-products .panel-default .panel-heading a { color: #D00233;
font-family: 'Roboto', sans-serif;
font-size: 14px;
text-decoration: none;
text-transform: uppercase;
}
.category-products .panel-default .panel-heading a:hover {background:#D00233; color:#fff;}
.category-products .panel-default .panel-heading:hover {background:#D00233; color:#fff !important;}
.category-products .panel-default .panel-heading .panel-title {
color: #D00233;
font-family: 'Roboto', sans-serif;
font-size: 14px;
text-decoration: none;
text-transform: uppercase;
}
.category-products .panel-default .panel-heading .panel-title:hover {color:#fff;background:#D00233;}
Please help me.
add this to the links and to the panel-title:
display: block;
width: 100%;
height: 100%;
in your case that would be:
.panel-title{
display: block;
width: 100%;
height: 100%;
}
.panel-title>a{
display: block;
width: 100%;
height: 100%;
}

how to change overflow?

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;

Categories