3

我想在这个 php echo 中添加一个浮动正确的样式

<?php echo $PAGE->button; ?>
<?php } ?>
4

6 回答 6

7

在 HTML 中:

<div class="foo">
    <?php echo $PAGE->button; ?>
    <?php } ?>
</div>

在 CSS 中:

.foo {
    /* some styles here */
}

或者只是简单地,但不推荐内联样式:

<?php echo "<div style='float: right;'>". $PAGE->button ."</div>"; ?>
于 2012-06-01T12:51:32.897 回答
1
<?php echo "<div style=\"float:right;\">" . $PAGE->button . "</div>"; ?>
<?php } ?>

这将使整个按钮向右浮动

于 2012-06-01T12:51:48.573 回答
0

您有几个选项,首选方法是在 CSS 文件中定义按钮的值:

  • 这可以降低开销,因为您不会在每个页面加载时加载更多字节,因为您可以将服务器设置为缓存样式表。

或者您脑海中的样式表:

  • 这不会为您节省带宽,但会使样式与 html 分离并保持样式到位。

或者您可以使用内联样式。

<style>
.button{
    float:right;
}
</style>

<!--Using the button class from the stylesheet, Notice how many less characters there is-->
<input type="button" value="Button" class="button" name="B3">
<br /> 

<!--Using the same class from the stylesheet, but wrapping the button within a span-->
<span class="button"><input type="button" value="Button" name="B3"></span>
<br /> 

<!--The inline method-->
<span style="float:right"><input type="button" value="Button" name="B3"></span>
于 2012-06-01T13:19:47.820 回答
0
<?php echo "<div style='float: right;'>". $PAGE->button ."</div>"; ?>
于 2012-06-01T12:51:41.070 回答
0

你不能给回声功能赋予风格。但是您可以将其包装在 lable 或 p 或任何其他 html 标记中并给出 float: 风格。

像这样,

<p style="float: right;"><?php echo $PAGE->button.?></p>
于 2012-06-01T12:52:46.363 回答
0

以更清洁的方式进行操作:

<div style="float: right;"><?php echo $PAGE->button; ?></div>
于 2012-06-01T12:54:02.910 回答