html改变button按钮位置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html改变button按钮位置相关的知识,希望对你有一定的参考价值。
我想移动到表单右下角
1、name : 表示按钮的名称,通常作为按钮标识进行使用。 <button name="btn">按钮</button>。
2、type : 表示按钮类型,通常与表单一起联用。reset : 重置按钮sumit : 提交按钮button : 普通按钮<button type="button">按钮</button>。
3、value : 表示按钮初始值,通常在js脚本中进行使用和修改。<button value ="点击">按钮</button>。
4、disabled :表示禁用按钮,使按钮不能点击<button disabled ="disabled">按钮</button>。
参考技术A 您好:改变页面元素位置,可以用绝对定位的方法即可:设置button的css样式。possition:absolute;然后设置top和left的值就可以控制他在页面的具体位置了。top是离上边界的距离,left是离左边界的距离。本回答被提问者和网友采纳 参考技术B表单放在一个div里面,div用position定位,别是static。然后按钮元素定位到右下角。
<head><style>
divposition:relative;
button
position:absolute;
right:0;
bottom:0;
</style>
</head>
<body>
<div>
<form>
<!--其他表单代码-->
<button>右下角按钮</button>
</form>
</div>
</body> 参考技术C style="padding-right:距离px;" 放在td或 div等里面
style="margin-right:距离px;" 放在 input 按钮里面
是table做的话 多做个td 用俩个或者3个td 最后一个td给整个table的3/1宽度中间的td里放按钮
按钮后面给空的代码 1一个代表1个空格
给按钮加上right="距离"
如果是绝对定位,可以设置left,还可通过margin,padding等 参考技术D 把表单放在<table>中试试
如何获得Button Click上的确切位置
我已按照此答案获取用户的确切位置。 https://stackoverflow.com/a/10917500/11118152 一旦他们改变了他们的位置(OnLocationChanged),我就得到了这个位置。但是,当我点击按钮时,我想要获得确切的位置。我该怎么做呢?如果用户离线,我应该让用户离线警告而不是最后一个已知位置。我该怎么做呢?
答案
尝试以下代码将帮助您: -
public class GPSTracker extends Service implements LocationListener {
private final Context mContext;
// flag for GPS status
boolean isGPSEnabled = false;
// flag for network status
boolean isNetworkEnabled = false;
// flag for GPS status
boolean canGetLocation = false;
Location location; // location
double latitude; // latitude
double longitude; // longitude
// The minimum distance to change Updates in meters
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
// The minimum time between updates in milliseconds
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
// Declaring a Location Manager
protected LocationManager locationManager;
public GPSTracker(Context context) {
this.mContext = context;
getLocation();
}
public Location getLocation() {
try {
locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE);
// getting GPS status
isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
} else {
this.canGetLocation = true;
// First get location from Network Provider
if (isNetworkEnabled) {
//check the network permission
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) mContext, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 101);
}
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("Network", "Network");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
// if GPS Enabled get lat/long using GPS Services
if (isGPSEnabled) {
if (location == null) {
//check the network permission
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) mContext, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 101);
}
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("GPS Enabled", "GPS Enabled");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return location;
}
/**
* Stop using GPS listener
* Calling this function will stop using GPS in your app
* */
public void stopUsingGPS(){
if(locationManager != null){
locationManager.removeUpdates(GPSTracker.this);
}
}
/**
* Function to get latitude
* */
public double getLatitude(){
if(location != null){
latitude = location.getLatitude();
}
// return latitude
return latitude;
}
/**
* Function to get longitude
* */
public double getLongitude(){
if(location != null){
longitude = location.getLongitude();
}
// return longitude
return longitude;
}
/**
* Function to check GPS/wifi enabled
* @return boolean
* */
public boolean canGetLocation() {
return this.canGetLocation;
}
/**
* Function to show settings alert dialog
* On pressing Settings button will lauch Settings Options
* */
public void showSettingsAlert(){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
// Setting Dialog Title
alertDialog.setTitle("GPS is settings");
// Setting Dialog Message
alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
// On pressing Settings button
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
}
});
// on pressing cancel button
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
alertDialog.show();
}
@Override
public void onLocationChanged(Location location) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
}
在活动中调用GPSTracker类: -
GPSTracker gpsTracker = new GPSTracker(getActivity());
if (gpsTracker.canGetLocation())
{
double latitude = gpsTracker.getLatitude();
double longitude = gpsTracker.getLongitude();
Geocoder geocoder;
List<Address> addresses = null;
geocoder = new Geocoder(getActivity(), Locale.getDefault());
try {
if (latitude != 0.0 && longitude != 0.0) {
addresses = geocoder.getFromLocation(latitude, longitude, 1);
}// Here 1 represent max location result to returned, by documents it recommended 1 to 5
if (addresses != null && !addresses.isEmpty()) {
address = addresses.get(0).getAddressLine(0); // If any additional address line present than only, check with max available address lines by getMaxAddressLineIndex()
String city = addresses.get(0).getLocality();
String state = addresses.get(0).getAdminArea();
S以上是关于html改变button按钮位置的主要内容,如果未能解决你的问题,请参考以下文章