首页 \ 问答 \ 通过php在bootstrap框架上生成的缩略图的正确对齐(Proper alignment of thumbnails generated via php on bootstrap framework)

通过php在bootstrap框架上生成的缩略图的正确对齐(Proper alignment of thumbnails generated via php on bootstrap framework)

我想将我的12列空间划分为3和9 col宽度的两个类别。在第一面我有一些信息,在第二列9宽度我希望通过php使用mysql显示自动生成的内容。这是第一面第一边代码:

<div class="container">
    <div class="row col-md-12">
<div class="col-md-3">
<div class="well">some content</div>
<div class="well1">some content2</div>
</div>

这是第二面自动生成的编码:

    <div class="col-md-9">


 <?php extract($_POST);
extract($_GET);
include "cw_admin/pageing.php";
$limit = 30;                                
if($page) 
$start = ($page - 1) * $limit;          
else
$start = 0;                     
$filePath="trending.php";
$select="select * from offers where trending='Yes' order by guid desc  Limit $start, $limit ";
$select1="select * from offers where trending='Yes'";
$result=mysql_query($select,$con);
$total=mysql_num_rows(mysql_query($select1,$con));
$otherParams="catid=$catid&shopid=$shopid"; 

        while ($row=mysql_fetch_assoc($result)) {
     $det=mysql_fetch_array(mysql_query("select * from category where id='$row[cat_id]'"));
     $shop=mysql_fetch_array(mysql_query("select * from shop where guid='$row[shopname]'"));?>
<div class="col-md-3">
<div class="thumbnail">

<?php if($shop[imagefile]!=''){?><img src="imagefiles/<?php echo $shop[imagefile];?>" class="img-responsive" "><?php } ?>

<div class="caption">
<h4 class="pull-right"><?php echo $row[rate];?></h4>
        <h4><?php echo $row[productname];?></h4>
 <p><?php echo $row[description];?></p>
         <p><?php if($row[offer_end]!='0000-00-00'){?>Offer Ends On: <?php echo $row[offer_end];}?></p>
        <p><?php if($row[coupon]!=''){?>Coupon Code:<?php echo $row[coupon];?><?php } ?></p>
 <?php 
                                 if($_SESSION[userid]!='')
                                { ?>
                                <a  href="<?php echo $row[main_url];echo "&";echo $row[affid];echo "&";echo $row[memid];echo "=";echo $details[userid];echo $row[deepid];?>"  target="_blank" class="btn btn-primary" > Earn <?php echo $row[value];?> Points</a>
                                <?php } 
                               else { ?>
                                <a  href="#1" data-toggle="modal" data-target="#myModal2" class="btn btn btn-primary" >Earn <?php echo $row[value];?> Cash</a>
                                <?php };
                                ?> 
</div>
</div>
</div>
<?php } ?>


</div>


</div>
</div>

我有两个问题:1)我给了2面作为col-md-9作为外部,col-md-3作为内部,但仍然在我的输出中列表中有4个项目。 2)即使缩略图的高度略有增加,也会导致下一行中缩略图的删除。请帮我解决这个问题。我被设计师骗了,所以不得不再做一切


I want to divide my 12 column space in to two categories of 3 and 9 col width.on the first side i have some information and on second 9 columns width i want to display automatically generated content through php using mysql.Here is the first side First side code:

<div class="container">
    <div class="row col-md-12">
<div class="col-md-3">
<div class="well">some content</div>
<div class="well1">some content2</div>
</div>

Here is the second side automatically generated coded:

    <div class="col-md-9">


 <?php extract($_POST);
extract($_GET);
include "cw_admin/pageing.php";
$limit = 30;                                
if($page) 
$start = ($page - 1) * $limit;          
else
$start = 0;                     
$filePath="trending.php";
$select="select * from offers where trending='Yes' order by guid desc  Limit $start, $limit ";
$select1="select * from offers where trending='Yes'";
$result=mysql_query($select,$con);
$total=mysql_num_rows(mysql_query($select1,$con));
$otherParams="catid=$catid&shopid=$shopid"; 

        while ($row=mysql_fetch_assoc($result)) {
     $det=mysql_fetch_array(mysql_query("select * from category where id='$row[cat_id]'"));
     $shop=mysql_fetch_array(mysql_query("select * from shop where guid='$row[shopname]'"));?>
<div class="col-md-3">
<div class="thumbnail">

<?php if($shop[imagefile]!=''){?><img src="imagefiles/<?php echo $shop[imagefile];?>" class="img-responsive" "><?php } ?>

<div class="caption">
<h4 class="pull-right"><?php echo $row[rate];?></h4>
        <h4><?php echo $row[productname];?></h4>
 <p><?php echo $row[description];?></p>
         <p><?php if($row[offer_end]!='0000-00-00'){?>Offer Ends On: <?php echo $row[offer_end];}?></p>
        <p><?php if($row[coupon]!=''){?>Coupon Code:<?php echo $row[coupon];?><?php } ?></p>
 <?php 
                                 if($_SESSION[userid]!='')
                                { ?>
                                <a  href="<?php echo $row[main_url];echo "&";echo $row[affid];echo "&";echo $row[memid];echo "=";echo $details[userid];echo $row[deepid];?>"  target="_blank" class="btn btn-primary" > Earn <?php echo $row[value];?> Points</a>
                                <?php } 
                               else { ?>
                                <a  href="#1" data-toggle="modal" data-target="#myModal2" class="btn btn btn-primary" >Earn <?php echo $row[value];?> Cash</a>
                                <?php };
                                ?> 
</div>
</div>
</div>
<?php } ?>


</div>


</div>
</div>

I have two questions: 1)i gave 2 side as col-md-9 as outer and col-md-3 as inner but still in my output there are 4 items in the list.! 2)Even if a small increase in the height of thumbnail it results in removal of thumbnail in the next row.Pls i am a new bie help me in this..we got cheated by a designer so had to do everything again


原文:
更新时间:2022-04-14 17:04

最满意答案

您的单元格需要观察另一个组合框中的值,以便它知道如果其中的值发生更改,则更新其禁用状态。

请注意,在单元格实现中还有其他错误:您必须考虑updateItem()方法中的所有可能性:例如,您没有正确处理null为空的项(单元格为空),或者将禁用状态设置为需要时假。 最后,在这里使用字符串作为数据类型既不方便(你可能必须在某些时候转换回int以使用这些值)并且弄乱逻辑(因为“10”小于“2”,例如)。 你应该在这里使用ComboBox<Integer>

这是一个只有两个“小时”组合框的实现:

import java.util.function.BiPredicate;

import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;


public class DependentComboBoxes extends Application {

    private ComboBox<Integer> startHours ;
    private ComboBox<Integer> endHours ;

    @Override
    public void start(Stage primaryStage) {
        startHours = new ComboBox<>();
        endHours = new ComboBox<>();
        startHours.setCellFactory(lv -> new StartHoursCell());
        endHours.setCellFactory(lv -> new EndHoursCell());
        for (int i = 0; i < 24 ; i++) {
            startHours.getItems().add(i);
            endHours.getItems().add(i);
        }

        GridPane root = new GridPane();
        root.setHgap(5);
        root.setVgap(5);
        root.addRow(0, new Label("Start hours:"), startHours);
        root.addRow(1, new Label("End hours:"), endHours);

        root.setAlignment(Pos.CENTER);
        root.setPadding(new Insets(20));
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }

    private class StartHoursCell extends ListCell<Integer> {

        StartHoursCell() {
            endHours.valueProperty().addListener((obs, oldEndHours, newEndHours) -> updateDisableState());
        }

        @Override
        protected void updateItem(Integer hours, boolean empty) {
            super.updateItem(hours, empty);
            if (empty) {
                setText(null);
            } else {
                setText(hours.toString());
                updateDisableState();
            }
        }

        private void updateDisableState() {
            boolean disable = getItem() != null && endHours.getValue() != null && 
                    getItem().intValue() > endHours.getValue();
            setDisable(disable) ;
            setOpacity(disable ? 0.5 : 1);
        }
    }

    private class EndHoursCell extends ListCell<Integer> {

        EndHoursCell() {
            startHours.valueProperty().addListener((obs, oldEndHours, newEndHours) -> updateDisableState());
        }

        @Override
        protected void updateItem(Integer hours, boolean empty) {
            super.updateItem(hours, empty);
            if (empty) {
                setText(null);
            } else {
                setText(hours.toString());
                updateDisableState();
            }
        }

        private void updateDisableState() {
            boolean disable = getItem() != null && startHours.getValue() != null && 
                    getItem().intValue() < startHours.getValue();
            setDisable(disable) ;
            setOpacity(disable ? 0.5 : 1);

        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Your cell needs to observe the value in the other combo box, so that it knows to update its disabled state if the value there changes.

Note you also have other bugs in the cell implementation: you must account for all possibilities in your updateItem() method: e.g. you don't properly deal with the item being null (the cell being empty), or setting the disable state back to false when needed. Finally, using strings as the data type here is both inconvenient (you presumably have to convert back to ints at some point to use these values) and messes up the logic (because "10" is less than "2", for example). You should use ComboBox<Integer> here.

Here's an implementation with just two "hours" combo boxes that works:

import java.util.function.BiPredicate;

import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;


public class DependentComboBoxes extends Application {

    private ComboBox<Integer> startHours ;
    private ComboBox<Integer> endHours ;

    @Override
    public void start(Stage primaryStage) {
        startHours = new ComboBox<>();
        endHours = new ComboBox<>();
        startHours.setCellFactory(lv -> new StartHoursCell());
        endHours.setCellFactory(lv -> new EndHoursCell());
        for (int i = 0; i < 24 ; i++) {
            startHours.getItems().add(i);
            endHours.getItems().add(i);
        }

        GridPane root = new GridPane();
        root.setHgap(5);
        root.setVgap(5);
        root.addRow(0, new Label("Start hours:"), startHours);
        root.addRow(1, new Label("End hours:"), endHours);

        root.setAlignment(Pos.CENTER);
        root.setPadding(new Insets(20));
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }

    private class StartHoursCell extends ListCell<Integer> {

        StartHoursCell() {
            endHours.valueProperty().addListener((obs, oldEndHours, newEndHours) -> updateDisableState());
        }

        @Override
        protected void updateItem(Integer hours, boolean empty) {
            super.updateItem(hours, empty);
            if (empty) {
                setText(null);
            } else {
                setText(hours.toString());
                updateDisableState();
            }
        }

        private void updateDisableState() {
            boolean disable = getItem() != null && endHours.getValue() != null && 
                    getItem().intValue() > endHours.getValue();
            setDisable(disable) ;
            setOpacity(disable ? 0.5 : 1);
        }
    }

    private class EndHoursCell extends ListCell<Integer> {

        EndHoursCell() {
            startHours.valueProperty().addListener((obs, oldEndHours, newEndHours) -> updateDisableState());
        }

        @Override
        protected void updateItem(Integer hours, boolean empty) {
            super.updateItem(hours, empty);
            if (empty) {
                setText(null);
            } else {
                setText(hours.toString());
                updateDisableState();
            }
        }

        private void updateDisableState() {
            boolean disable = getItem() != null && startHours.getValue() != null && 
                    getItem().intValue() < startHours.getValue();
            setDisable(disable) ;
            setOpacity(disable ? 0.5 : 1);

        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)