GVKun编程网logo

css – 如何在使用引导程序激活时更改按钮颜色?(引导样式)

12

本文将带您了解关于css–如何在使用引导程序激活时更改按钮颜色?的新内容,同时我们还将为您解释引导样式的相关知识,另外,我们还将为您提供关于AlertDialog更改按钮颜色、android–如何在点

本文将带您了解关于css – 如何在使用引导程序激活时更改按钮颜色?的新内容,同时我们还将为您解释引导样式的相关知识,另外,我们还将为您提供关于AlertDialog更改按钮颜色、android – 如何在点击时更改按钮的颜色并暂停屏幕几秒钟?、asp.net – 如何在使用Html.TextAreaFor时更改字体和颜色?、css – 使用引导程序滑出面板的实用信息。

本文目录一览:

css – 如何在使用引导程序激活时更改按钮颜色?(引导样式)

css – 如何在使用引导程序激活时更改按钮颜色?(引导样式)

我正在使用bootstrap 3.我想在点击按钮时更改按钮颜色.我的意思是按钮在选中时应该是不同的颜色.我怎么能用css做到这一点?

我的代码是:

<divid="">
    <button type="submit"id="1">Button1</button>
    <button type="submit"id="2">Button2</button>
</div>

解决方法

CSS有不同的伪选择器,您可以通过它实现这种效果.在你的情况下你可以使用

:active : if you want background color only when the button is clicked and don’t want to persist.

:focus: if you want background color untill the focus is on the button.

button:active{
    background:olive;
}

button:focus{
    background:olive;
}

JsFiddle Example

P.S.:请不要给出html元素的Id属性中的数字.

AlertDialog更改按钮颜色

AlertDialog更改按钮颜色

如果没有调用Show 方法AlertDialog.getButton(DialogInterface.BUTTON_POSITIVE) 为 null。AlertDialog 的逻辑是 show()方法 中初始化了 AlertDialog 上面的控件,然后展示出来,所以在 show()方法 执行之后才能得到 button。

  final AlertDialog alertDialog = new AlertDialog.Builder(this).setTitle("sdd")
.setPositiveButton("kk",null).setNegativeButton("取消",null)
.setNeutralButton("dd",null).create();
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
                button.setTextColor(Color.GREEN);
            }
        });
alertDialog.show();



不用费劲的去改主题了

---------------------

本文来自 cike978 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/cike978/article/details/74530488?utm_source=copy 

android – 如何在点击时更改按钮的颜色并暂停屏幕几秒钟?

android – 如何在点击时更改按钮的颜色并暂停屏幕几秒钟?

我正在研究 android测验.我想添加按钮.当我点击它更改图像或颜色并按住按钮一段时间来检查答案,如果答案是正确的,那么它显示绿色和错误的红色.

我已经在最后按钮上实现了颜色更改,但我不明白如何实现Handler延迟: –

public class QuestionActivity extends Activity implements OnClickListener{

    private Question currentQ;
    private GamePlay currentGame;




    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.question);
        processSession();

    }
    private void processSession(){
                /**
         * Configure current game and get question
         */
        currentGame = ((CYKApplication)getApplication()).getCurrentGame();
        currentQ = currentGame.getNextQuestion();
        Button nextBtn1 = (Button) findViewById(R.id.answer1);
        nextBtn1.setonClickListener(this);
        Button nextBtn2 = (Button) findViewById(R.id.answer2);
        nextBtn2.setonClickListener(this);
        Button nextBtn3 = (Button) findViewById(R.id.answer3);
        nextBtn3.setonClickListener(this);
        Button nextBtn4 = (Button) findViewById(R.id.answer4);
        nextBtn4.setonClickListener(this);
        Button nextBtn5 = (Button) findViewById(R.id.answer5);
        nextBtn5.setonClickListener(this);
        /**
         * Update the question and answer options..
         */
        setQuestions();

    }


    /**
     * Method to set the text for the question and answers from the current games
     * current question
     */
    private void setQuestions() {
        //set the question text from current question
        String question = Utility.capitalise(currentQ.getQuestion());
        TextView qText = (TextView) findViewById(R.id.question);
        qText.setText(question);

        //set the available options
        List<String> answers = currentQ.getQuestionoptions();
        TextView option1 = (TextView) findViewById(R.id.answer1);
        option1.setText(Utility.capitalise(answers.get(0)));

        TextView option2 = (TextView) findViewById(R.id.answer2);
        option2.setText(Utility.capitalise(answers.get(1)));

        TextView option3 = (TextView) findViewById(R.id.answer3);
        option3.setText(Utility.capitalise(answers.get(2)));

        TextView option4 = (TextView) findViewById(R.id.answer4);
        option4.setText(Utility.capitalise(answers.get(3)));


        int score = currentGame.getscore();
        String scr = String.valueOf(score);
        TextView score1 = (TextView) findViewById(R.id.score);
        score1.setText(scr);
      try{ 
         new CountDownTimer(20000,1000) {

            public void onTick(long millisUntilFinished) {
                TextView timers = (TextView) findViewById(R.id.timers);
                timers.setText("" + millisUntilFinished / 1000);
            }

            public void onFinish() { 
                currentGame.decrementscore();
                processSession();
                   }
         }.start();
      }
      catch(Exception ex)
      {
          throw new RuntimeException(ex);
      }
        }


    @Override
    public void onClick(View arg0) {
        //Log.d("Questions","Moving to next question");
        if(arg0.getId()==R.id.answer5)
        {
        new AlertDialog.Builder(this).setMessage("Are you sure?").setCancelable(true).setPositiveButton("Yes",new DialogInterface.OnClickListener() {


        public void onClick(DialogInterface dialog,int id) {
                finish();
                 }
             }).setNegativeButton("No",null).show();

                }

        else
        {

            if(!checkAnswer(arg0)) return;  

        /**
         * check if end of game
         */
        if (currentGame.isGameOver()){
            //Log.d("Questions","End of game! lets add up the scores..");
            //Log.d("Questions","Questions Correct: " + currentGame.getRight());
            //Log.d("Questions","Questions Wrong: " + currentGame.getWrong());
            Intent i = new Intent(this,EndgameActivity.class);
            startActivity(i);
            finish();
        }
        else{
            Intent i = new Intent(this,QuestionActivity.class);
            startActivity(i);
            finish();
          }
        }
      }



    @Override
    public boolean onKeyDown(int keyCode,KeyEvent event)
    {
        switch (keyCode)
        {
        case KeyEvent.KEYCODE_BACK :
            return true;
        }

        return super.onKeyDown(keyCode,event);
    }


    /**
     * Check if a checkBox has been selected,and if it
     * has then check if its correct and update gamescore
     */
    private boolean checkAnswer(View v) {
     try {
     final Button b=(Button) v;
     final String answer = b.getText().toString();
     counterTimer.cancel();
     b.setBackgroundResource(R.drawable.ans);
     b.setEnabled(false);

     //Log.d("Questions","Valid CheckBox selection made - check if correct");


         handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                 if( (currentQ.getAnswer().equalsIgnoreCase(answer)))
                {
                    b.setBackgroundResource(R.drawable.ansgreen);
                    //Log.d("Questions","Correct Answer!");
                    currentGame.incrementscore();
                }
                else{
                    b.setBackgroundResource(R.drawable.ansred);
                    //Log.d("Questions","Incorrect Answer!");
                    currentGame.decrementscore1();
                }
           }
         },10000000);

       } catch (Exception e) {
           e.printstacktrace();
       }
     return true;
}

任何答案都很明显.

提前致谢

解决方法

我已经在按钮上实现了这个代码来改变按钮上的颜色.希望它适合你.

private boolean checkAnswer(View v) {

            Button b=(Button) v;
            String answer = b.getText().toString();

            b.setBackgroundResource(R.drawable.ans);

                 b.setEnabled(false);

                if (currentQ.getAnswer().equalsIgnoreCase(answer))
                {
                    b.setBackgroundResource(R.drawable.ansgreen);
                }
                else{
                    b.setBackgroundResource(R.drawable.ansred);
                }
                return true;
            }

处理器

if (currentGame.isGameOver()){
            //Log.d("Questions","Questions Wrong: " + currentGame.getWrong());
            final Handler handle = new Handler();
            Runnable delay = new Runnable() {
                public void run() {

                    finish();
                    startActivity(new Intent(QuestionActivity.this,EndgameActivity.class));
                }
            };
            handle.postDelayed(delay,1000);
        }
        else
        {
            final Handler handle = new Handler();
            Runnable delay = new Runnable() {
                public void run() {

                    finish();
                    startActivity(new Intent(QuestionActivity.this,QuestionActivity.class));
                }
            };
            handle.postDelayed(delay,1000);
                  }
              }

asp.net – 如何在使用Html.TextAreaFor时更改字体和颜色?

asp.net – 如何在使用Html.TextAreaFor时更改字体和颜色?

我正在使用以下代码显示一些文字,它不会改变字体颜色,任何人都知道为什么?

<%= Html.TextAreaFor(m => m.Component.ApplicationDescription,new { cols = "40%",Style = new Style { ForeColor = Color.Red } })%>

解决方法

<%= Html.TextAreaFor(m => m.Component.ApplicationDescription,})%>

或应用CSS风格:

<%= Html.TextAreaFor(m => m.Component.ApplicationDescription,@})%>

这看起来像这样:

.foo {
    color: red;
}

css – 使用引导程序滑出面板

css – 使用引导程序滑出面板

我使用twitter引导,并尝试做类似的事情 here(滑出面板).
我已经看到nav-collapse效果非常相似,除了它从上面掉下来,只出现在某个屏幕尺寸以下.希望现有的代码可以使用效果

http://codepen.io/Tyriar/pen/nJGfj

可能吗?

谢谢.

解决方法

我以前使用过JavaScript的插件叫做SnapJS:
https://github.com/jakiestfu/Snap.js/

这里有一些有用的实现演示:
http://jakiestfu.github.io/Snap.js/demo/apps/default.html

今天关于css – 如何在使用引导程序激活时更改按钮颜色?引导样式的讲解已经结束,谢谢您的阅读,如果想了解更多关于AlertDialog更改按钮颜色、android – 如何在点击时更改按钮的颜色并暂停屏幕几秒钟?、asp.net – 如何在使用Html.TextAreaFor时更改字体和颜色?、css – 使用引导程序滑出面板的相关知识,请在本站搜索。

本文标签: