0

So I am trying to add some CSS styles to a php form I have the following 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 pphp element of the web page using the id="button" attribute.

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.

How would i do this?

Thanks in advance.

4
  • The button it the submit element of the form Commented Apr 17, 2016 at 14:40
  • 1
    Do you mean 20px rather than 20ex; Commented Apr 17, 2016 at 14:40
  • However it does not apply the style from the CSS to this button. All of the styles? only one? few? Commented Apr 17, 2016 at 14:42
  • can u try using class? Commented Apr 17, 2016 at 15:41

6 Answers 6

1

You can change your css submit to this. Instead of using an id button

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; 
}
Sign up to request clarification or add additional context in comments.

7 Comments

so the css file would look like #button input[type=submit] or just input[type=submit]?
Still wouldn't work because ex is not a CSS measurement unit.
@MarkEriksson Sorry I just copied the css given and didn't noticed that. my bad
@bdg just input[type=submit]
If it helps add up. Thanks
|
1

This should work

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

2 Comments

Still wouldn't work because ex is not a CSS measurement unit.
@mark-eriksson rofl, i didnt read his css code just edited the selector :P you're right. It should be px or em ..
0

Your issue was your CSS measurement unit, ex is not valid in CSS. Perhaps you meant px or em but I'm guessing px by the value size you provided. 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;
}

Comments

0

try to use button tag and then add css to it's id. You can execute action on button click by javascript $(#yourid).click(function(){ //you action goes here. });

Comments

0

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)

<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;
} 
?>

Comments

0

You can use id also, but in CSS you need to add this code:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.