通过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
原文:
最满意答案
您的单元格需要观察另一个组合框中的值,以便它知道如果其中的值发生更改,则更新其禁用状态。
请注意,在单元格实现中还有其他错误:您必须考虑
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 useComboBox<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); } }
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如何禁用Combobox项目?(How to Disable Combobox Items?)[2021-07-14]
编辑:看起来你找到了一种方法来获取ComboBoxItems。 您可能还想查看ItemContainerStyle并查看是否有一些DataBinding可以利用(如果您的项目具有Enabled属性或类似的东西)。 但是,根据您使用DataBinding的方式,您可以使用DataTemplates在不同的画笔,不透明度等中显示“禁用”项目。 Bea Stollnitz 在这里有一篇很好的帖子。 从UX的角度来看,您可能想要考虑的一件事是,为什么要将它们设为禁用而不是隐藏。 是否存在某种渐进式披露策略,您可以利 ... -
这是您应该避免使用原始类型的原因之一。 您的ChangeListener被编写为您正在侦听IntegerProperty而不是Property
。 无法将Unit_Type对象转换为Integer因此您在此表达式中获得异常: unitList.get((int) arg2) 如果使用ChangeListener ,您的编译器会抱怨此问题。 您可以改为监听selectedIndex属性(当然,检查有效索引 - -1也是可能的值)。 简单地将列表作为属性添加到Unit_ ... -
JavaFX:使comboBox单元动态更改禁用状态(JavaFX: Make comboBox cell to change disable state dynamically)[2023-07-19]
我创建了一个名为CustomNumber的对象以跟上禁用的属性。 关键代码: 此代码设置组合框的文本并启用其单元格。 Callback, ListCell > factory = lv -> new ListCell () { @Override protected void updateItem(CustomNumber item, boolean empty) { super ... -
你可以做 var sortedItems = myLookupProperty.Items.OrderBy(x => x.WhateverPropertyYouWantToSortOn); myLookupProperty.Clear(); foreach (var item in sortedItems) { myLookupProperty.Add(item); } 这对你有用。 您尝试的第一种方法不起作用的原因(正如我想象的那样)是它只是将新项目附加到底部。 您提出的第二种方法不起作用的原因是您 ...
-
这正是“关于将节点插入ComboBox项目列表的警告” 文档中引用的示例。 组合框中的项目列表应表示数据 - 而不是用于显示数据的UI组件。 问题是HBox在场景图中不能出现两次:因此它既不会出现在“选定的单元格”中,也不会出现在下拉列表中的单元格中。 而是创建一个表示您在ComboBox中显示的数据的类,并使用单元工厂指示ComboBox如何显示这些数据。 一定要设置一个纽扣电池(用于所选项目的单元格)。 This is exactly the example cited in the documenta ...
-
使用组合框的selectedvaluechanged属性加载启动一个sub,该子类触发第二个组合框的查询。 你看到在下面的代码中使用'me.initiallyloaded'属性,组合框的缺点是它在首次加载表单时也会触发。 使用此布尔值可防止这种情况。 Private Sub ComboBoxClients_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripComb ...
-
我不完全理解为什么这是必要的,但是为了让传递给setOBox的控件的SetHandAction()方法的EventHandler,必须首先使用show()方法显示舞台。 import javafx.application.*; import javafx.stage.*; import javafx.scene.*; import javafx.scene.layout.*; import javafx.scene.control.*; public class Test extends Applicat ...
-
您的单元格需要观察另一个组合框中的值,以便它知道如果其中的值发生更改,则更新其禁用状态。 请注意,在单元格实现中还有其他错误:您必须考虑updateItem()方法中的所有可能性:例如,您没有正确处理null为空的项(单元格为空),或者将禁用状态设置为需要时假。 最后,在这里使用字符串作为数据类型既不方便(你可能必须在某些时候转换回int以使用这些值)并且弄乱逻辑(因为“10”小于“2”,例如)。 你应该在这里使用ComboBox
。 这是一个只有两个“小时”组合框的实现: import ...