简体   繁体   English

样式化PHP表单<input type=“submit”>

[英]styling a php form <input type=“submit”>

So I am trying to add some CSS styles to a php form I have the following CSS 所以我试图将一些CSS样式添加到php表单中,我有以下CSS

#button {
  font-size: 14;
  border:none;
  width:20ex;
  height:10ex;
  outline: none;
}

which I would like to add this to the form which is constructed within the p php element of the web page using the id="button" attribute. 我想将其添加到使用id="button"属性在网页的p php元素内构建的表单中。

From what I have read this should work. 根据我的阅读,这应该可行。

$list = '';
while($row = $result->fetch_assoc()){
$title = $row['title'];
$id = $row['id'];
$summary = $row['summary'];
//I'm assuming you want each link to be different here...
$list.='<div class="Select_Course"><form name="courseselect" method="post" action="selectedcourse.php">
        <input type="submit" name="subsearch" value="' .$title. '" id="button">
        <input name="submitcourseselection" type="text" value="'.$title.'"hidden> 
        </form>
        <p>' . $summary . '</p></div>';
} 

However it does not apply the style #button from the CSS to this button. 但是,它不会将CSS中的样式#button应用于此按钮。

How would i do this? 我该怎么办?

Thanks in advance. 提前致谢。

You can change your css submit to this. 您可以更改CSS提交到此。 Instead of using an id button 代替使用id按钮

input[type=submit] {
    padding:5px 15px; 
    font-size: 14px;
    border:none;
    width:20ex;
    height:10ex;
    outline: none;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px; 
}

This should work 这应该工作

input[type="submit"] {
    font-size: 14;
    border:none;
    width:5em;
    height:2.5em;
    outline: none;
}

Your issue was your CSS measurement unit, ex is not valid in CSS. 您的问题是CSS度量单位, ex在CSS中无效。 Perhaps you meant px or em but I'm guessing px by the value size you provided. 也许您的意思是pxem但我根据您提供的值大小猜测px This should do the trick 这应该可以解决问题

#button {
  font-size: 14px; /*added px*/
  border:none;
  width:20px; /*changed to px*/
  height:10px; /*same as above*/
  outline: none;
}

try to use button tag and then add css to it's id. 尝试使用按钮标签,然后将css添加到它的id中。 You can execute action on button click by javascript $(#yourid).click(function(){ //you action goes here. }); 您可以通过javascript $(#yourid).click(function(){//您的操作在此处进行。

Following code is working for me in Firefox(For this example i am using $i since I do not know your Database and i have change the font-size to 15 and echo the list) 以下代码在Firefox中为我工作(对于此示例,由于我不知道您的数据库,因此我在使用$ i,并且将字体大小更改为15并回显了列表)

<style>
#button{
font-size: 15;
border:none;
width:20ex;
height:10ex;
outline: none;
}
</style>

<?php
$list = '';
$i=0; //For this example i am using $i since I do not know your Database 
while($i<6){
$title = 'Title-'.$i;// change this to your database variable $row['title']
$id = $i;// change this to your database variable $row['id']
$summary = 'Summary: '+$i;// change this to your database variable $row['summary']
//I'm assuming you want each link to be different here...
$list.='<div class="Select_Course">
    <form name="courseselect" method="post" action="selectedcourse.php">
    <input type="submit" name="subsearch" value="' .$title. '" id="button">
    <input name="submitcourseselection" type="text" value="'.$title.'"hidden> 
     </form>
    <p>'.$summary.'</p>
    </div>';    
$i++;   

echo $list;
} 
?>

You can use id also, but in CSS you need to add this code: 您也可以使用id,但是在CSS中,您需要添加以下代码:

input[id="button"] {
    font-family: "Calibri";
    font-size: 18px;
    background-color:#FF4500;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM